Home › Forums › General Issues › Querying a Post Object relation field inside a repeater › Reply To: Querying a Post Object relation field inside a repeater
Hi @charlesr
It seems that you forgot to add the functions to change the SQL query. Could you please check the link I gave you again (please check the section “4. Sub custom field values”)?
I believe you need to do it like this:
// filter
function my_posts_where( $where ) {
$where = str_replace("meta_key = 'person_department_%", "meta_key LIKE 'person_department_%", $where);
return $where;
}
add_filter('posts_where', 'my_posts_where');
// args
$args = array(
'numberposts' => -1,
'post_type' => 'people',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'person_department_%_person_department_select', // this should be the first sub-field
'value' => get_the_ID(),
'compare' => '='
),
array(
'key' => 'person_department_%_person_department_head', // this should be the second sub-field
'value' => true,
'compare' => '='
)
)
);
I hope this helps 🙂
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 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.