Home › Forums › Add-ons › Repeater Field › Querying a relationship field in a repeater field › Reply To: Querying a relationship field in a repeater field
Hi @jloupf
I think I found the issue. It seems ‘post_where’ filter won’t work with get_posts()
function. To fix it, you need to set suppress_filters
option to false
. Please take a look at the note on this page: https://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where.
So, your code should be something like this:
$formations = get_posts(array(
'suppress_filters' => FALSE,
'post_type' => 'formation',
'meta_query' => array(
array(
'key' => 'chapitres_%_lecon', // name of custom field
'value' => '"' . get_the_ID() . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
'compare' => 'LIKE'
)
)
));
if( $formations ): ?>
. . .
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.