I'm using a WP_Query inside one of my functions.
function get_id_list ($postType) {
$wpb_all_query = new WP_Query(
array(
'post_type' => $postType,
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_query' => array(
array(
//'key' => 'title',
//'value' => 'Wordpress Development BSP Project', // this works and the function only returns a list with the single ID of the post where this matches
'key' => 'bicslab_axis',
'value' => '22', // this does not work
'value' => 'greenware', // this does not work
)
)
)
);
$postIDList = [];
if($wpb_all_query->have_posts()){
while ( $wpb_all_query->have_posts() ) {
$wpb_all_query->the_post();
$postIDList[] = get_the_ID();
}
wp_reset_postdata();
}
print_r($postIDList);
return $postIDList;
}
The query works correctly when in the 'meta_query'
I choose a key which is a field of type "text", but it does not if I choose a field of type "relationship".
Here is a screenshot of my advanced custom fields:
For the relationship fields I tried putting the ID and the name, none of them would work.
How would I do it to make the query retrieve only posts where custom field of type relation is related to only some objects?
Edit: I should clarify, I used "22"
respectively "greenware"
as values in my mea query because 22 is the ID and greenware is the "name" of the specific blog post/object with that id