Hey guys.
So, I have 3 fields attached to a post – Edited By, Revised By and Written by.
The field types are „user field” with multiple values selectable.
They are set to output an object.
I want to query posts in an author archive page and get only the posts that have that author attached to them in one of the 3 fields.
And here we get to the meta query:
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'post_revised',
'value' => '',
'compare' => 'IN',
),
array(
'key' => 'post_edited',
'value' => '',
'compare' => 'IN',
),
array(
'key' => 'post_written',
'value' => '',
'compare' => 'IN',
),
),
Which is the value I should check for? User ID, object?
Thanks in advance!
Users are stored by ID and you need to use “LIKE” with quotes around the ID.
an example:
array(
'key' => 'post_revised',
'value' => '"'.$user_id.'"',
'compare' => 'LIKE',
),