There’s two possible solutions to this:
1. All posts have meta
The best solution I have found here is to give the rest of the posts/products an item price of 0. You can do this manually, or loop through all the posts and if the price is empty then update it.
To make this manageable in the future you can hook into save_post
and give them a value when they are first added (only if it’s blank).
2. Multiple Queries
You could run the first query as you’re doing and store the IDs of the posts returned. You could then run another query for all posts and orderby date, excluding the IDs return from the first query.
You can then print out the two results separately order and you’ll get the desired results.
Related Posts:
- multiple orderby in pre_get_posts action
- How to alter query order direction using $query->set(‘order’, ‘ASC’); inside a pre_get_posts filter?
- Use pre_get_posts to sort meta_key by an array of values
- Why does pre_get_posts() return “date” as the orderby parameter for every sortable column?
- Check post_date in pre_get_posts
- pre_get_posts shows posts in random order sometimes
- Sort by DESC works, ASC doesn’t?
- Sort posts by meta value with get method
- How to order posts by parents?
- Using Orderby and meta_value_num to order numbers first then strings
- WP_Query orderby post__in remains ineffective in the Loop [closed]
- How to Change Order of Posts in Admin?
- get_the_terms in descending alphabetical order
- next and previous post link ordered alphabetically
- Order posts by meta_value even if meta_key is not filled
- Order by first name
- Meta query interfering with orderby relevance
- Order posts by (hierarchical custom) taxonomy terms and term children
- the_tags() : display the tags by the order they are typed in in the backend, not alphabetically
- Sort custom post types by last name in the backend
- Sorting Attributes order when using get_the_terms
- Filter query posts by the count of metas for a meta key
- How to order posts by meta value?
- How Do I Order Posts by Modified Date? [duplicate]
- Orderby Post Views
- How to order posts (woocommerce products) alphabetically but ignore certain words, eg ‘The’ and ‘An’
- How to order posts by alphabet with numbers at the end
- Best Plugin to Reorder Post Types
- Ordering system through WordPress
- pre_get_posts order by not working
- Issue with multiple orderby values
- get_query_var returns wrong default value
- orderby meta_value breaks taxonomy term archives
- Show first the posts from 1 specific tag
- Order posts by price
- All, published and pending order
- get_adjacent_post() returning weird results
- Get_Users Orderby Page
- Sort order of next/prev sibling page
- Help ordering Post loop by two meta values
- Order ascending is ignored in meta query?
- Order char by post title
- next_post_link and previous_post_link order not working properly
- query pages by a childs publish date
- WordPress Screwing Up ‘orderby’ => ‘meta_value_num’ in ‘pre_get_posts’
- List most recently added posts (with a twist)
- WP Query – order posts by meta field first and then order the rest
- Featured-Content/Featured Posts With Random Order
- Orderby in Query Posts affected by operating system?
- Ordering posts by title containing numbers
- Stylesheet Enqueue Order and Best Practices
- wp_list_pages sort order by top nav menu order and child of
- How to display taxonomy terms the way they are hierarchical
- wp_list_categories() by alphabet? (ex. only category titles that start with “A”) [closed]
- Child pages not affected by orderby
- Order by ASC, DESC, Title, Date from URL on custom page template post
- Offset posts with random order
- view subcategories order by id
- Sort query output on taxonomy term archive by post type using pre_get_posts
- ASC and DESC separately from orderby
- Order WP_Query by The Order of an Array in Tax_Query
- struggling to order by title
- Order by two meta values – one is a number and the other is text
- Order posts by taxonomy terms
- Last post sorting get_categories
- Order resultset by configured value and then list all the rest
- Order column custom date using pre_get_posts
- Shop sends Mail with order cancellation
- List of terms in alphabetical order under the respective initial letter and within columns
- update_post_meta saves data but does not show in Order backend
- Random order not working correctly when using default loop + $query->set
- Changing cache update rate
- how to complete order status automatically after paypal payment received
- Order management including recurring orders on woocommerce
- Orderby Title not working
- Why does this incorrect pre_get_posts meta_query work for sort order?
- Sort loop by title doesn’t sort single digits like human would
- What’s the most efficient way to get two queries based on an if statement?
- How to order custom user list columns by datetime?
- Creating a post that contains a list of other posts like a table of contents
- Want to order by Meta Values (tweaking Post Order Widget)
- Order posts by custom column using pre_get_posts
- Changing posts order on a page
- Re-order posts inside tax query
- Pre_Get_Posts order DESC not registering
- Ordering Subcategories
- single post navigation order (NOT chronological)
- Problem with meta_value order after update
- Random order of posts on each request
- How can I make have_posts() return posts ordered DESC by id?
- Add post order like page order
- Woocommerce Pre Orders view order link wrong [closed]
- How to make WordPress orderby work with post_excerpt column?
- Orderby with menu_order and title
- Sort wordpress posts by facebook likes [closed]
- How to use orderby on meta_value when using Pods custom database table storage
- Sorting by date not working?
- How to put posts with some taxonomy on top of others in `pre_get_posts`
- Admin products page column not sorting
- How can meta values from another site in a multisite be used in a custom query?