Allright guys, a bit of a headache here:
I’ve got three custom post types: poem, author and collection.
Relationships are set from the poem CPT: every poem has an author and a collection relationship field.
I’m now trying to access from the author page every poem written by him/her through a ‘meta_query’, like this:
$poems = get_posts(array(
'post_type' => 'poems',
'meta_query' => array(
array(
'key' => 'author',
'value' => <strong>???</strong>,
'compare' => 'LIKE'
)
)
));
The problem is that author is a relationship field that will return an object. I would like to compare the ‘author’ custom field’s name or id to a value, but I would need to get the name/id value from the first element of the ‘author’ array.
I hope I have managed to succesfully explain my problem.
That said, does anybody know how I could do that or if that’s even possible?
(I’ve thought about a custom SQL query but I couldn’t find a way)
Thanks!
Well, looks like the solution was much easier than I expected.
The query does already compare the ID field to your value.
Such a long post for nothing :/