Home Forums General Issues WP_Query with ACF Group and Repeater


WP_Query with ACF Group and Repeater

  • Hello all.
    I have a question, how to get a post using WP_Query.
    Where meta_query is Group -> Repeater -> Repeater value.
    I tried adding a filter:

    function my_posts_where( $where ) {
         $where = str_replace( "meta_key = 'Group_Repeater_$", "meta_key IN 'Group_Repeater_%", $where );
         return $where;
    add_filter( 'posts_where', 'my_posts_where' );

    And then retrieve the posts like this:

    $args = array(
        'posts_per_page'  => 12,
        'post_type'   => 'custom_post_type',  
        'meta_query'  => array(
        'key' => 'Group_Repeater_$_RepeaterInnerKey', 
        'value' => array( 'val1', 'val2', 'val3' ), 
        'compare' => 'IN' 
    $the_query = new WP_Query( $args ); 

    But it doesn’t find anything. Maybe someone has encountered it, I’d be grateful for a hint.

    $where = str_replace( "meta_key = 'Group_Repeater_$", "meta_key LIKE 'Group_Repeater_%", $where );

    4. Sub custom field values

  • What if need to pass multiple values in the value?
    Should I use LIKE?

  • You are altering the field name that you are looking in by altering the where statement, your are not altering the values you are looking for.

    WHERE meta_key LIKE "group_repeater_%_subfield" AND meta_value IN ......

    The instructions are to alter the first part, not the second

  • Thank you so much for the tip.
    That helped.

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

You must be logged in to reply to this topic.