Home › Forums › Front-end Issues › Query custom post type depending on post object inside a repeater › Reply To: Query custom post type depending on post object inside a repeater
Then you need to build the query for each lawyer ID. I believe it should be something like this:
// initialize the meta query
$meta_query = array('relation' => 'OR');
// Add the query for each lawyer ID
foreach( $lawyers_ids as $lawyers_id ) {
$meta_query[] array(
'key' => 'book_authors',
'value' => '"' . $lawyers_id . '"',
'compare' => 'LIKE'
);
}
// Get the books
$books = get_posts(array(
'post_type' => 'book',
'paged' => $paged,
'posts_per_page' => -1,
'meta_query' => $meta_query,
));
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.