Query posts by custom fields (object post)

As described in ACF documentation, here is the way to find all posts where a custom field called ‘color’ has a value of ‘red’.

$posts = get_posts(array(
‘numberposts’ => -1,
‘post_type’ => ‘post’,
‘meta_key’ => ‘color’,
‘meta_value’ => ‘red’
));

But in my case, I need to find all posts where the ID of an object post custom field has a certain ID.

How should I proceed to handle meta_value as an object, and targeting its ID key?

Read more here:: Query posts by custom fields (object post)

Leave a Reply

Your email address will not be published. Required fields are marked *