Support

Account

Home Forums Front-end Issues Shortcodes in text field

Solved

Shortcodes in text field

  • I have created a text field called ‘code’ and inside of it, I’ve put a shortcode;

    [formidable id=8]

    However on the front end, it doesn’t word and only shows the field as text rather than activating the shortcode.

    <?php echo do_shortcode( ' '. the_field('code') .' ' ); ?>

    Any ideas how to get it to work?

  • I found this on the web. Don’t know a lot about custom shortcodes, but I tested this and it worked.

    $shortcode = get_post_meta($post->ID,'YOUR_CUSTOM_FIELD_NAME',true);
    echo do_shortcode($shortcode); 
  • You can also add an acf/format_value filter, this exact example is covered here https://www.advancedcustomfields.com/resources/acf-format_value/

    set the priority > 10

  • Thanks for all the comments, I solved it by adding the following to my functions.php

    add_filter('acf/format_value/type=textarea', 'do_shortcode');

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.