Forums Forums General Shortcodes in excerpt

Tagged: 

Viewing 9 posts - 11 through 19 (of 19 total)
  • Anonymous
    #206075

    As to ACF fields. Let us assume it is a single value field use key is my_custom_field and the prefix required is My Custom Field Value, then the PHP is this:

    I did it and it works. But again, there is a shortcode (button) in this field and it’s not working. Just showing me shortcode texts:
    https://drive.google.com/open?id=17Y89ciQhBGyEegIogWIVu8UgCDow67Ao

    How to solve it?

    Trevor
    #206079

    Did you try wrapping that code in a do_shortcode function?

    <?php if( get_field('my_custom_field') ):?>
    <p>My Custom Field Value: <?php do_shortcode(the_field('my_custom_field')); ?></p>
    <?php endif; ?>

    I am not sure if that would work. Otherwise you may need to use PHP string functions to fetch the string as before, then split it up into before the button shortcode, the shortcode and the what comes after, and then handle them, with the shortcode being output in a do_shortcode function.

    Anonymous
    #206083

    It doesn’t work ((

    I am not very savvy in php. But I need this button to display.

    Trevor
    #206085
    This reply has been marked as private.
    Anonymous
    #206099
    This reply has been marked as private.
    Trevor
    #206101
    This reply has been marked as private.
    Anonymous
    #206103
    This reply has been marked as private.
    Trevor
    #206182

    I changed the code to this:

    <?php if( get_field('purchase') ):?>
    <p><?php echo do_shortcode(get_field('purchase')); ?></p>
    <?php endif; ?>
    Anonymous
    #206192

    Thanks! All is working as intended. Thanks for the support.

    Waiting for a new version with default taxonomy value. =)

Viewing 9 posts - 11 through 19 (of 19 total)