This should help:
You can use multiple fields in orderby
argument. Codex shows you how to do it (and you do it correctly):
$query = new WP_Query( array( 'post_type' => 'page', 'orderby' => 'menu_order date', 'order' => 'ASC' ) );
And it should solve your problem. (It should, but if you want to sort DESC it probably won’t, because of this WordPress bug: http://core.trac.wordpress.org/ticket/17065)
Of course you always can use posts_orderby
filter to create your own ORDER BY
part of query.
function my_posts_orderby($orderby_statement) {
$orderby_statement = "YOUR ORDER BY STATEMENT";
return $orderby_statement;
}
add_filter('posts_orderby', 'my_posts_orderby');
Just add this filter just before you call your query and remove it after.
Related Posts:
- How do I order pages and categories by ID or name in the same query?
- WordPress altering my custom query, How to fix it?
- If orderby parameter using pre_get_posts is the same for multiple posts what fallback does the query use?
- Change default ordering of taxonomy terms – pre_get_terms
- WP_Query Excluding pages with Order is 0
- How to set multiple `orderby` in query argument?
- Woocommerce – Changing the order of the upsell products [closed]
- Can I use WP_Query to find a post with a particular menu_order?
- WordPress get_posts function, 1300 lines long
- Exclude a category if post is only in that category using wp_Query
- Too slow when using both ‘tax_query’ and ‘meta_query’ both in WP_Query
- Use of caller_ get_ posts
- Tax_query terms ID’s using variable
- Pagination custom query
- WP_Query and name__in
- Query certain amount of posts from multiple dates
- Order posts by tags count?
- Orderby = none not working [duplicate]
- Querying Multiple Custom Taxonomy Terms
- Show list of authors with latest post NOT older than a month
- Unable to combine “search value” and “tax_query” using WP_Query
- How to extend tag and category “Related Posts” query to custom post_type if the first 2 terms have no posts
- WP_Query search for whole words
- WP_QUERY returns empty set when fired from a WP-CRON scheduled event
- Interupting the loop with extra divs to display data, and how to get it to work responsively
- WP_Query, tax_query and term_meta: How to?
- How do I reset this wp_list_categories query?
- How to pass many ids in post__in?
- Sub-loop / nested loops Best Practices
- How to echo data after a WP_Query
- Query with a meta value inside a given range
- Pagination of a WP_Query Loop in a child-page page template
- Add condition of user capability in WP_query
- How do I run through a WordPress loop called from a filter function?
- How do I get the title of a category in a custom loop?
- WooCommerce – get product sub categories
- Order by empty custom field
- Warning: Invalid argument supplied for foreach(). when creating a WP_query
- Help ordering Post loop by two meta values
- How to exclude post formats from wordpress recent posts in a tabs widget [closed]
- New WP_Query loop in admin causes problems
- How to sort a custom wordpress query by combination of meta values?
- How to pass orderby params to $wpdb->prepare()?
- Get author if post has multiple authors
- Hide posts with meta key in WP_Query
- how update data through ajax and jquery
- What happens to the default query when I use WP_Query?
- Combine results of multiple WP_Query to resemble single WP_Query
- Modifing archive query affects show post count function
- Using WP_Query() in Magento shows error
- For what queries is conditional tags informative?
- Utilising an existing page while using the “s” query parameter
- posts archive page – closing WP_Query loop correctly [closed]
- JSON – Create rest api endpoint for Advanced Custom Fields
- AJAX Breaking Offset Argument In WP Query
- Is it possible (and how to) query single Gutenberg blocks?
- Get meta_value of a specific meta_key from all posts belonging to a specific custom type
- Nested array issue in meta_query
- Query by key or author
- WP_query paged pagination with excluded category still counts it
- meta_query with array as value with multiple arrays
- Why doesn’t my WP Meta Query return any results?
- How to build the WP_Query using the code?
- How go give $value to wp_query
- Show multiple tax_query from 2 or more post_type in a single code
- How to make the ‘request’ filter work?
- How to use rewind_comments() – when and how to use it?
- Filter for each loop when WP_Query has no posts to show
- Related categories order posts by category
- How do I use $wp_query->current_post with get_template_part? I’m trying to add post classes (first/last/even/odd) to custom loops
- Why pagination is not working with tax_query param?
- Finding post ID dynamically on click
- paginate_links method doesn’t show second page of my custom wp_query
- Wp_Query Post per page not working?
- Order Element By Custom Field in WordPress
- Display All Top Child Categories / Taxonomy
- how to get custom attachment url?
- ACF Post Object meta-query by title not ID
- Case insensitive ORDERBY in wpquery
- Sorting with meta_query and multiple, optional meta keys
- getting posts by tags
- WP_Query & Duplicate entries
- Query child posts with tax query on parents
- How to break up output of posts for different terms on same page?
- From admin edit user page query either the user_nicename or username field value of the user profile being edited or viewed
- Calculating efficiently on large amount of data generated by wp_query
- Include post_status check within $wpdb query
- Return on a quest all these meta_value
- Inline Ajax call after term is appended with a @ or # etc. displayed in div
- Complicated WP_Query
- Custom query to show posts
- New WordPress WP Query using posts from certain categories
- Taxonomy related query not working
- How to show featured post first, then separate loop for other posts
- error with $query->have_posts()
- Multiple Orderby is not working right
- I want to place a post before all others from an ACF boleen field
- How to put posts with some taxonomy on top of others in `pre_get_posts`
- wp_query, calculate with two dates when ‘key’ is text format
- Use value from meta key array for use in WP_Query