Home › Forums › Add-ons › Repeater Field › Query repeater field with two values › Reply To: Query repeater field with two values
I have this code example for a project if it helps (it’s not WP_Query but get_posts, seance is my custom post type, seances a repeater field and film is a relationship field) :
<?php
$today = date("Ymd");
$date = strtotime($today);
$seances = get_posts(array(
'suppress_filters' => FALSE,
'post_type' => 'seance',
'meta_key' => 'date',
'orderby' => 'meta_value_num',
'order'=>'ASC',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'seances_%_film', // name of custom field
'value' => '"' . get_the_ID() . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
'compare' => 'LIKE'
),
array(
'key' => 'date',
'compare' => '>=',
'value' => $today,
)
)
));
?>
And in functions.php
function my_posts_where( $where ) {
global $wpdb;
$where = str_replace(
"meta_key = 'seances_",
"meta_key LIKE 'seances_",
$wpdb->remove_placeholder_escape($where)
);
return $where;
}
add_filter('posts_where', 'my_posts_where');
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We’re reaching out to our multilingual users to ask for help in translating ACF 6.1. Help make sure the latest features are available in your language here: https://t.co/TkEc2Exd6U
— Advanced Custom Fields (@wp_acf) May 22, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.