Easy peasy!
$args_for_query1 = [
'post_type' => 'custom_project',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => '_thumbnail_id'
)
)
];
$args_for_query2 = [
'post_type' => 'custom_project',
'post_status' => 'publish',
'meta_key' => '_thumbnail_id',
'meta_compare' => 'NOT EXISTS',
];
$query1 = new WP_Query($args_for_query1);
$query2 = new WP_Query($args_for_query2);
$wp_query = new WP_Query();
$wp_query->posts = array_merge( $query1->posts, $query2->posts );
$wp_query->post_count = $query1->post_count + $query2->post_count;
Related Posts:
- meta_query with meta values as serialize arrays
- Use REGEXP in WP_Query meta_query key
- How to query posts based on lat-lng coordinate as post meta?
- Set Alias for meta_query arguments in get_posts()
- How to Compare Two Meta Fields
- Is it possible to orderby multiple meta_keys when using meta_value_num?
- Getting attachments by meta value
- Using custom meta_query with relation not working as expected
- WP_Query meta_query where meta value ends in space
- Nested query inside Logical operator OR not working in meta_query
- What is an efficient way to query based on post_meta?
- WP_Query not working as expected for attachments and custom meta_query
- How do I create my own nested meta_query using posts_where / posts_join?
- WooCommerce: filter by parent product’s taxonomy and product variation’s meta data
- How to order a post type with meta_value_num and if meta_value_num does not exist then order by date
- Exclude post on loop by multiple meta key value
- How to query ‘posts_per_page’ to display a different blog posts index template?
- Order By Multiple Meta Fields
- Advanced WP Query hogs the SQL server
- Order posts by meta value and Date
- Query sticky posts with thumbnails
- How to get user_id from wordpress database inside ajax function?
- Meta query with order by another custom field
- WP_Query with multiple meta fields filter?
- How to combine meta_query and post__in in WP_Query
- How to orderby meta_value_num with dollar ($) sign
- Order a query result by a numeric meta key even if it does not exist, but put the posts with meta key first
- Single meta_query query using OR instead of AND in request’s WHERE statement
- Meta Query Array Error 500
- How to do meta_query for attachments?
- SQL: What is wrong with the following query (generated by WordPress WP_Query, ordering prices)
- Why isn’t my `meta_query` array functioning properly?
- Overwrite YoastSEO meta-tags with another page’s [closed]
- How to orderby multiple meta fields if some fields are empty
- Fetch Record based on meta key dates
- Suggestions on making this query/code more performant
- Order by meta value (numeric value lower to higher)
- Large AND OR query timing out
- WP_Query with different postmeta filter for each categories
- meta_query not working as expected
- Slow WP_Query with ‘OR’ on meta_query
- How to filter a query by multiple meta keys and order by other meta keys
- Query posts with “non set” meta value
- Ordering a mysql style datetime stamp with meta_query
- Meta Query doesn’t works as espected
- Wp_query with 2 meta keys and array of meta values
- Advanced WP_Query with meta_query, orderby?
- meta_query: check if number exists
- Event with multiple dates, display events chronologically
- Issues with search after added meta_query
- Display posts with specific value first in query
- it’s possible make a WP_Query with math operations?
- Sorting search results with custom dropdown
- WP_Query: apply an SQL function to meta fileld value
- How to search for meta_query LIKE or tax_query LIKE and grab these posts on search results?
- How to create dynamic value in WP_Query meta_query
- query post by author gender
- How do I add an item to the WP admin menu?
- Multiple meta query from array
- WP_Query with 4 post meta field arguments gives 500 internal server error
- Use have_posts() with array of post results retrieved by $wpdb->get_results
- What’s missing in this wp_query and meta_query
- ACF: How to query for a given value count of an array like field? (e.g.: How many rows has a `flexible_content` field?)
- Custom meta_query order for Elementor based on post meta key [closed]
- What’s wrong with this meta query? (order by meta key, then title, doesn’t work)
- ElasticPress is (aparently) messing with my search filters
- Meta query ignores multiple values of the key
- Multiple meta_query not returning rows
- meta_query order by date present -> future then show null
- Check for not NULL not working in meta query
- Get unique post by meta value using wp_query
- Query against multiple locations within single custom post type post
- WP_Query, ACF field and array
- Order by Date Custom Field
- WP Query. Ordering posts by another post types meta
- meta_query compare > not working
- Complex Meta Query
- Get posts meta_query by repater field
- Query 3 meta_key and orderby
- wp_query sorting – one specific meta_key value at last and then sort by create date
- Saving custom fields for WP_Query to retrieve
- meta_query not working with the_content()
- Filter posts/pages by user_role array
- WP_Query with MetaQuery issue
- Custom loop – Isolating post meta output depending on current query taxonomy terms
- Get closest event where meta_key field is an array
- WP_Query with meta_value_num and meta_query not paged correctly
- Post Query not working after updating to 4.1
- Orderby Meta Value and Query from Meta Query
- The sorting of posts by a meta_query with two keys fails while separated as single queries it works
- Set right order for query that returns posts based on two custom fields
- Sort posts in dashboard using custom field; also include posts where field isn’t set
- Sort Posts with custom meta key by default which is currently set as optional
- Meta_query weird behaviour
- WP_Query with several meta_query-statements and order by meta_value
- WordPress extremely slow when using get_posts with multiple meta_query relations
- Use meta query only 3 or more results?
- Use value from meta key array for use in WP_Query
- WordPress – Optimize the Meta Query for 3 meta keys at a time
- WP_Query filtering in ACF field containing dates