Support

Account

Home Forums Front-end Issues Text strings displayed instead of shortcode

Solving

Text strings displayed instead of shortcode

  • I’ve created a checkbox field with the ACF plugin so the user could select additional features for the product in the Woocommerce to be displayed after the product description. Choices in the checkbox:

    [html_block id="9060"] : Saadaval käetoega
    [html_block id="9045"] : Ladustamise võimalus

    The additional features are HTML blocks and the checkbox values are the shortcodes for these HTML blocks.

    The problem is that the raw text value of the shortcode is displayed on the product page rather than the HTML block itself. Inside the product description there is a [acf field="toote_omadus"] to call out the ACF input.

    I’ve already researched similar issues on this forums but they usually are limited regarding just single text area.

    I’ve already tried add_filter('acf/format_value/type=textarea', 'do_shortcode'); in the functions.php file which doesn’t seem to work.

    Maybe someone is able to point in the right direction?

  • Got this to work by using PHPCode snippets. If anyone else encounters this issue in the future:

    <?php
    $array = get_field( "FIELD_NAME" );
    
    foreach($array as $value){
            echo do_shortcode($value);
    }

    Then I just submit the PHPCode Snippet shortcode [xyz-ips snippet="SHORTCODE_NAME"] after the product’s description in wordpress editor.

  • Since you are using a checkbox field then the filter

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

    is wrong and you would need to run the filter on each array value of the checkbox.

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

You must be logged in to reply to this topic.