Not sure how to achieve this. I’m trying to mix standard posts and custom posts on a site homepage but I only want to display the custom posts if a meta value is set. Displaying the posts works fine 'post_type' => array('game', 'post')
but when I add in the meta_query the regular posts are no longer displaying (which makes sense as they don’t meet the meta_query condition).
So how do I limit the meta_query to only the custom post type so that the regular post will still be included?
There are different way to do the trick, 2 comes into my mind:
$wpdb
queryWP_Query
with filters, usingWP_Meta_Query
to build the additional sqlI’ll post here sample code for case #2
See inline comments for further explaination.
Also look at WP_Meta_Query on Codex for complete docs on how to set your meta query args.
Edit
I refactored code in a reusable plugin, using a class. Available as Gist.