Support

Account

Home Forums Add-ons Repeater Field Only show post if subfield has certain value Reply To: Only show post if subfield has certain value

  • I need some clarification what you are trying to do with your code above…

    Because this: <?php if( get_sub_field(‘category’, 8) ): ?> …means that you are trying to check if post ID 8 has a sub field ‘category’.

    If this is not what you want but instead want to see if sub_field ‘category’ has the value 8 you can do it like this:

    <?php
    $variable = get_sub_field(‘category’);
    if ($variable && $variable == ‘8’) {
    echo ‘Yes this post has a field category with value 8’;
    }
    ?>

    But as I’m not fully aware of your situation, I’m also thinking that you may be confusing actual wordpress categories and custom fields and if that’s the case, you code needs a whole different approach.