Support

Account

Home Forums Add-ons Repeater Field Using Repeater Post Object as Conditional Statement

Helping

Using Repeater Post Object as Conditional Statement

  • I’ve configured my products to use the repeater fields to show post objects. I’d now like to query this data and use as a conditional statement, so if a product uses a specific post object within it’s repeater.

    For example;

    if(has_acf_post_object(‘post-object-slug’)) {
    wc_get_template_part( ‘content’, ‘product’ );
    }

    Is this possible?

  • ACF does not have have what you’re looking for built in. You’d need to create this yourself, but it could be done.

    You’d need to create a function that would look through the repeater field of the post and see if any of the sub fields contains a reference to the post object you’re looking for. The function would need to be built to match all of the fields and relationships specific to you’re post types and custom fields.

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

The topic ‘Using Repeater Post Object as Conditional Statement’ is closed to new replies.