If you want both posts that have and do not have a meta key, you need an OR
relation meta query to select both posts with key and those where it does not exist.
$args = array(
'meta_query' => array(
'relation' => 'OR',
array(
'key' => '_post_like_count',
'compare' => 'EXISTS'
),
array(
'key' => '_post_like_count',
'compare' => 'NOT EXISTS'
)
),
'orderby' => 'meta_value_num post_date',
'order' => 'DESC'
);
$recent = new WP_Query( $args );
Related Posts:
- Use REGEXP in WP_Query meta_query key
- Getting attachments by meta value
- What is an efficient way to query based on post_meta?
- WP_Query not working as expected for attachments and custom meta_query
- How can I create a WP_Query that returns posts where one meta_value
- WordPress altering my custom query, How to fix it?
- WP Meta Query for some meta (array) values
- How to get sum of meta_values of a meta_key in wp_query according to conditions
- Get meta info related to current post
- How to make Meta Query case sensitive?
- Performance when getting post meta for post retrieved by meta value
- Get attachment by meta_key value
- Fetch Record based on meta key dates
- how to make members list directory through wordpress post custom meta key.
- Large AND OR query timing out
- Filter posts by comparing custom meta value against postdate
- Nested array issue in meta_query
- Query posts by searching for a string in a meta field
- WP_Query meta compare must include ALL array values
- How do i create a custom post query when the meta value is an array?
- wp query to use both author id and meta_query
- Meta query ignores multiple values of the key
- Trouble with serialized metadata
- show most viewed post
- Why can my filter query SOME metadata but not other metadata?
- Query against multiple locations within single custom post type post
- How to set meta_query if get_post_meta returns nested array for that key? [duplicate]
- Saving custom fields for WP_Query to retrieve
- How to show all the associated posts with specific date of data metabox?
- WP Meta Query at depth 2
- WP_Query Posts by Metadata from Option Tree
- Return a single custom post from multiple meta queries
- WP_Query by meta key not returning any posts
- Can wp_query return posts meta in a single request?
- How do I query for posts by partial meta key?
- compare meta_query in get_posts arguments
- Display products from specific category in shop page
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- meta_query where value is equal to given value
- Order by meta_value_num DESC and meta_value ASC on WP 4.0
- Query by meta_key and order by meta_value_num return orderby date
- Wp_query order by multiple custom fields?
- WP Query post meta value
- Would this post meta be better added to the post table rather than post_meta table
- How to query ‘posts_per_page’ to display a different blog posts index template?
- Order by meta_key in custom post type doesn’t affect the query
- How to create/modfiy WP_Query to search in post title OR custom field?
- Efficient way to update multiple post meta
- How to get user_id from wordpress database inside ajax function?
- 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
- Meta Query Array Error 500
- Order by meta value (numeric value lower to higher)
- meta_query not working as expected
- WP_Query with offset and ‘orderby’ => ‘rand’, offset not working
- Query posts with “non set” meta value
- Is it possible to retrieve all posts with a certain value for metadata?
- Ordering a mysql style datetime stamp with meta_query
- Wp_query with 2 meta keys and array of meta values
- meta_query: check if number exists
- Event with multiple dates, display events chronologically
- Orderby two meta fields not working
- WP Query / Meta Query [duplicate]
- Query multiple post types, but different order for each
- How to add date_query to meta_query array
- Order by the first array within a meta_query
- Query ACF relationship field – Comparator IN – Value array
- Combine query in WP_User_Query()
- Multiple nested meta queries
- How to _GET multiple value checkbox WP_Query in Custom Toxonomy / Custom Fields
- How can I modify the query by adding to the existing query?
- WordPress Query custom ordering by temporary variable
- Comparing Meta Field date in WPQuery using Meta_Query?
- How to create better WP_Query to look for date time which is anywhere between two meta values?
- WP_Query, ACF field and array
- Filtering WP_Query based on wp_postmeta keys values
- Look for string in posts and postmeta
- Query postmeta based on meta_value, return array of post_id
- Multiple meta_query not working
- compare for multiple meta values for same key in wp_query
- datetime picker, timestamps and meta queries
- WP_Query with meta_query won’t orderby
- meta_query only check if both value are set
- Meta key in wp_query bug?
- Efficient way of querying for a “fallback” post?
- Extending WP Query: Custom geolocation meta values work, but tax_query breaks
- Using custom field as ‘orderby’ value causing post grouping by publish date
- Sorting Posts with meta value not working
- How to query post ids liked by the Author
- Meta_query weird behaviour
- loop through custom post types with meta data
- Looking for a way to exclude frontpage and nav menu from query filter
- Creating Custom Query
- Get posts by meta value except one post [closed]
- How to get all post_id and meta_value using meta_key in wp_postmeta table
- WP Query – Show custom posts only if user contain some user meta
- How do I subquery with custom meta fields?
- Extend search query to search meta keys values based on search string