Hello,
i’m getting crazy.
i have different CPT ( hotel, markes, city, etc… )
My relationship field is used to link those CPT to cities.
Now in a page ( hotel page ) i want to link “other hotels in same city”.
how can i make my query ? I know how to do a query by ID with the ID of actual page, but what i need is :
$city = get_field(‘contact_city’);
$query = display all hotels with contact_city as $city
But i didn’t find any solution.
If only 1 value in relation field :
$city_id = $bnb_ville[0]->ID;
if it could be more than 1 value :
$city_id = [];
foreach ($var as $post) {
$city_id[] = $post->ID;
}
$bnb_ville is the variable for get_field() !