How to output a shortcode?

Support General How to output a shortcode?Resolved

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #27222
    KaraKara
    Participant

    Hi there - I'm starting a new thread since other was marked as solved without detailing how.

    I need to add a shortcode to a CPT in the backend using a custom field that will then show on the front end. Is this possible?

    #27226
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Thank you for reaching out.

    Please follow this documentation to know how to use the shortcode [ rwmb_meta ]
    https://docs.metabox.io/shortcode/

    #27237
    KaraKara
    Participant

    Hi Long - thanks for your quick response.

    Let me clarify - I don't want to create a shortcode of the Meta Box custom field, I need to add an existing shortcode from another plugin (in this case to show a registration form on the front end).

    Here's my workflow:
    Create CPT > Add custom field for shortcode > copy/paste registration form shortcode into custom field > registration form is visible on the front end.

    If it matters, I'll be using Elementor to pull the custom fields to a template for the CPT.

    Maybe there is a function I can add to my theme file to let me add shortcodes to the custom HTML field?

    #27252
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Thank you for your additional information.

    If you want to insert a shortcode from another plugin, you can just use the widget Shortcode of Elementor to insert it, no need to insert via a custom field.

    Or you can insert a shortcode via the field type WYSIWYG https://docs.metabox.io/fields/wysiwyg/

    #30904
    AstwertAstwert
    Participant

    Hello Long.

    I inserted in WYSIWYG-Field a shortcode from Plugin "Content Blocks (Custom Post Widget)".

    But if i use rwmb_meta("acf-single-prod-summary-prolog") it outputs only the string of shortcode like this: [content_block slug=s-prod-summary-prolog-3dportrait]

    I came from "acf", it had always worked there.

    Hope there is a solution.

    Thank you in advance

    André

    #30906
    AstwertAstwert
    Participant

    I've now noticed that there is a need to run an extra line of code.

    echo do_shortcode( wpautop( $value ) )

    I work with Oxygenbuilder's repeater element.
    I have no way of executing this code in it.
    Is there a way i can basically define the output as rendered, or do you have another idea?

    Thank you in advance

    André

    #32222
    tilen.stilen.s
    Participant

    Hey there, is there any solution to this?
    I have also migrated from ACF to MB and I can as well confirm that in ACF shortcodes as values were generated properly on front end. Now with Metabox, using similar settings, shortcode is generated as text on front end.

    [oxygen-template id="746"]: Label 1
    [oxygen-template id="795"]: Label 2
    #32224
    AstwertAstwert
    Participant

    I switched back to ACF temporarily until there is an solution.
    As you can see the support is bad here.
    A pity

    #32225
    tilen.stilen.s
    Participant

    Astwert, if it helps in any way, for one of my simple use cases (not in repeater) I'm applying a workaround to put all possible shortcodes inside oxy template and make use of MetabBox fields for display conditions. It's a pain but it works.

    @MetaBox, any guidance (or better yet a properly integrated solution to this) would be highly appreciated.

    #32233
    Long NguyenLong Nguyen
    Moderator

    Hi friends,

    As you can read on the documentation, the helper shortcode [rwmb_meta] supports rendering the inner shortcode inside the field value. You need to set the attribute render_shortcode to true.
    https://docs.metabox.io/shortcode/

    #33054
    indatext.comindatext.com
    Participant

    Yup, '[rwmb_meta id="seo_text" render_shortcode="true" raw="true"]' renders TablePress shortcodes for example.

    #33080
    tilen.stilen.s
    Participant

    Well, part of the solution can also be found in https://support.metabox.io/topic/output-shortcode-from-a-custom-field/.

    I can however, with posts in this thread and in the before mentioned thread, got it to work as expected.

    #35306
    FernandoTWEFernandoTWE
    Participant

    I have the same problem and the rendering option does not work.

    I have a custom field that contains a shortcode but it does not render the shortcode. Can you fix this?

    #35326
    Long NguyenLong Nguyen
    Moderator

    Hi Fernando,

    Which is the field type of the custom field? And how do you display the field value? You can use the field wysiwyg to render the shortcode inside the field content. Read more on the documentation
    https://docs.metabox.io/fields/wysiwyg/
    https://docs.metabox.io/shortcode/

    #35327
    FernandoTWEFernandoTWE
    Participant

    I have tried all possible fields.

    With ACF it is easier, it can render the shortcode correctly but MB cannot.

    My process is as follows:

    I create a custom field for post type "post" with name shortcode. When I customize a template with Oxygen Builder, I include the custom field.

    When viewing an example it only displays the shortcode as follows [shortcode] in text format without being able to render it.

Viewing 15 posts - 1 through 15 (of 17 total)
  • You must be logged in to reply to this topic.