Home › Forums › General Issues › Query with Relationship field › Reply To: Query with Relationship field
Hi James
Thank you for your help, it works !
I’ve tried with an array of ID, it doesn’t work, it returns an empty array.
Here is what I’ve done, unfortunately it doesn’t work…
Do you have an idea ?
Thank you very much for your time.
<?php
$preargs = array(
'post_type' => 'offres'
);
$the_query = new WP_Query( $preargs );
$offres_id = array(); //added
while ( $the_query->have_posts() ) : $the_query->the_post();
$offres_id[] = get_the_ID();
endwhile;
// $arraydeidoffre RETURNS : array(7) { [0]=> int(25747) [1]=> int(25356) [2]=> int(24140) [3]=> int(23097) [4]=> int(23054) [5]=> int(22286) [6]=> int(12005) }
$propositions = get_posts(array(
'post_type' => 'proposition',
'numberposts' => -1,
'meta_query' => array(
array(
'key' => 'offre_liee',
'value' => $offres_id,
'compare' => 'IN'
)
)
));
var_dump($propositions);
?>
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.