Custom Text Field with Shortcode not showing up correctly on frontend

Support General Custom Text Field with Shortcode not showing up correctly on frontendResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #38500
    Denise FieldDenise Field
    Participant

    Hi

    I have a custom shortcode that sits inside a text field.
    [myshortcode]

    I have added it to my php file using this code.

    <?php $value = rwmb_meta( 'size_guide' ) ?>
    	<p><?= $value ?></p>

    Instead of outputting the content of the shortcode, its just showing the shortcode name on the frontend.
    i.e.
    [myshortcode]

    Can anyone help?

    #38508
    Long NguyenLong Nguyen
    Moderator

    Hi,

    You can use the WordPress function do_shortcode() to render the shortcode on the frontend.

    <?php $value = rwmb_meta( 'size_guide' ) ?>
    <p><?php echo do_shortcode( $value ); ?></p>

    Read more on the documentation https://developer.wordpress.org/reference/functions/do_shortcode/

    #38510
    Denise FieldDenise Field
    Participant

    Thank you that worked!

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