Home Forums ACF PRO Conditional Logic – Shortcode


Conditional Logic – Shortcode

  • Hello,

    To summarize, I am using the following three types of fields that use a conditional logic:

    [wpbb post:acf type=’true/false’ name=’breed’]

    [wpbb post:acf type=’select’ name=’pure_breed’]

    [wpbb post:acf type=’multi select’ name=’mixed_breed’]

    The first field titled ‘breed’ is a true/false. If the user chooses true when making a blog post, I would like the ‘pure_breed’ content to get populated onto the website. If the user chooses false, I would like the ‘mixed_breed’ content to get populated onto the website. I am making this a wordpress API shortcode to simply have to type [dog_breed] on my website template page to populate the breed in a particular location. I have no experience with coding and this is what I came up with from a combination of websites such as and your code examples. Please see the following code below, I cannot get it to display.

    add_shortcode ( ‘dog_breed’, function(){
    $term = get_field( ‘breed’ );


    {$term = get_field( ‘pure_breed’ );
    echo $term->name;
    echo $term->description;

    {$term = get_field( ‘mixed_breed’ );
    echo $term->name;
    echo $term->description;

    return ob_get_clean(); });


Viewing 1 post (of 1 total)

The topic ‘Conditional Logic – Shortcode’ is closed to new replies.