Support

Account

Home Forums Add-ons Repeater Field query posts with repeater field

Helping

query posts with repeater field

  • Hi, I love your plugin and I’ve purchased the repeater field add-on. However, I’m struggling with getting all custom post types that match a field in a repeater field.

    In other words, I have a post type “writers” with two fields, “location” which is a normal field, and “genre” which is a repeater field.

    I need to retrieve all writers with location = Los Angeles and genre = mystery, so I tried this:

    $p2 = get_posts(array(
    	'numberposts' => -1,
    	'post_type' => 'writers',
    	'meta_key' => 'location',
    	'meta_value' => 'los-angeles',
    	'meta_query' => (array('key' => 'genre', value => 'mystery'))
    ));

    …but that didn’t work. Is there a way to use get_posts to query repeater fields?

  • Hi @pnoeric

    the meta_query argument does not work like this.

    To query sub field data, you need to follow this tutorial here:
    http://www.advancedcustomfields.com/resources/tutorials/querying-the-database-for-repeater-sub-field-values/

    Thanks
    E

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

The topic ‘query posts with repeater field’ is closed to new replies.