ACF repeater field with meta_query

How can I use a repeater field with meta_query I have a repeater field with some text values only and have a form that sends variables to a page where I get the value and storage a value which is the VALUE in the meta_query, I want to get all the CPT that hast certain string in a repeater field for example:

if(isset($_GET['tecnology'])){
$tech = $_GET['tecnology'];
echo $tech;
}

if(isset($_GET['category'])){
    $cat = $_GET['category'];
    echo $cat;
}

if(isset($_GET['start'])){
    $star_point = $_GET['start'];
    echo $star_point;
}

$args = array(
    'post_type' => 'project',
    'posts_per_page' => -1,
    'orderby' => 'post_date',
    'meta_query' => array(

        array(

            'key' => 'tecnologies',
            'value' => $tech,
            'compare' => 'LIKE'
        ),
        array(
            'key' => 'category_project',
            'value' => $cat,
            'compare' => 'LIKE'
        ),
        array(
            'key' => 'route', //this is the repeater field
            'value' => $star_point, // this is the string I want to know if it´s in the repeater field
            'compare' => 'LIKE'
        )
    )
    );
  $loop_servicios = new WP_Query( $args ); 
?>

1 Answer
1

I don’t think it’s possible. ACF stores repeater data in separate postmeta fields – one database row for every field in the repeater – so you would have to query multiple fields, and unless you always have the same number of repeater fields, you wouldn’t even know how many to query.

It sounds like you would be better off structuring your data a little more heavily by making custom taxonomies. Taxonomy queries are also much, much faster than meta queries, so performance will be much better.

Leave a Comment