2

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 ); 
?>
2
  • You should look up XSS and see how your code allows it.
    – Joel M
    Jan 21, 2020 at 3:40
  • ok nvm i guess i can see ur not going to leave the echos there.
    – Joel M
    Jan 21, 2020 at 3:41

1 Answer 1

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.