Support

Account

Home Forums ACF PRO Allow shortcodes to process in ALL custom fields

Solving

Allow shortcodes to process in ALL custom fields

  • Is there a way to make it so any custom field will accept and process shortcodes? I’ve seen countless threads on this topic all around the Web with ways to make WordPress process shortcodes if you explicitly identify each field by name. I’m wondering if there’s a way to make it so all custom fields will accept shortcodes without needing to set up a function naming each one.

    I’d like to retrofit a bunch of sites with a function to process shortcodes, and it would take weeks to run through every site, get the name of every field and script out each one by name. Is there any way to do this across the board, so I can drop in the function on 40-50 sites and all fields are now able to use them? For example, I have a simple shortcode – [tm] – that spits out <sup>&trade;</sup>. I want client to be able to add [tm] into any field, and get the HTML equivalent.

    Can this be done? Thanks!

  • Only the WYSIWYG Editor is capable of interpreting Shortcodes, else you have to echo the shortcode

    
    $shortcode = get_field('shortcode');
    echo do_shortcode(' . $shortcode . ');

    Cheers
    Johannes

  • You can also add a format value filter to specific field types or all fields. The example on this page shows adding a filter for textarea fields to do shortcodes. https://www.advancedcustomfields.com/resources/acf-format_value/

    Doing this on all fields would not make sense, for example a taxomomy or relationship field. Trying to do shortcodes on fields that return array or object values would destroy the array/object.

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

The topic ‘Allow shortcodes to process in ALL custom fields’ is closed to new replies.