Since version 4.0 is available 'type'
option for 'orderby'
argument in WP_Query
.
Also, thanks to the more powerful ORDER BY in WordPress 4.0 you can control how posts of a post type are ordered.
Example (untested):
$q = new WP_Query(array(
'post_type' => array('map','item'),
'orderby' => array(
'type' => 'DESC',
'title' => 'ASC'
)
));
Related Posts:
- Get Terms by IDs with IDs order
- simple sql query on wp_postmeta very slow
- How to Use Wildcards in $wpdb Queries Using $wpdb->get_results & $wpdb->prepare?
- wordpress query – orderby child post date
- Slow wp_enqueue_media()
- Compare two numeric custom fields
- Custom query filter not working on woocommerce category page
- How to delete a transient on post/page publish?
- How to extract all ID variables from a query string?
- WordPress creating excessive joins on meta_query with search
- How to display liked posts of current user in wordpress?
- Sorting Grids with Essential Grid and Events Manger
- The use of including upgrade.php when building custom queries
- Remove Unnecessary Mysql Query
- Get the timout value of a saved transient?
- Grouping related postmeta data via SQL query
- Does meta_query work within get_posts array?
- How to remove duplicate query on page load or make them cacheable
- wpdb::prepare() isn’t working
- How can I apply a meta query for a single custom post type in the main query?
- WordPress Find Duplicate Post By Content
- how to query multiple categories in wordpress?
- Disable the MySQL query in the main query
- Huge amount of queries on my site
- Using pre_get_posts to target a query in the sidebar
- Update slug (URL) of pending posts via phpMyAdmin
- How can I get the query that would be run for the archive page?
- Query metas (and not : query posts by metas)
- How do I use get_query_var() within plguin code
- How to display related posts by same publish date?
- where should I reset query after using get_results?
- Get post according to current taxonomy
- Exclude featured image and custom field from this get_attachment query
- Ordering by a metadata subfield in WordPress?
- Alter query with posts_clauses to retrieve NULL values last
- Query based on title, with ‘compare’ => ‘IN’
- Issue with using add_rewrite_rule() for post querying custom fields
- Form and custom query problem
- Export Specific User data without plugin
- Plugin will sort users by usermeta
- Exclude all sticky posts front page twenty twelve
- Query posts according to specific post meta values
- wpdb COALESCE won’t work
- get csv of users with user_meta
- empty query breaks other queries
- Problem in exploding the_content to array
- Query does not return content
- What is wrong with my wp query, cant exclude the category that i want
- how to insert missing tags into the posts through mySQL?
- How to write update query in WordPress to expire transients
- Query Nickname rather than Display Name in custom Woocommerce plugin
- get posts by tag to showing in a widget
- Get previous posts list
- how to replace old DW site with new WP site? [closed]
- WordPress SQL query to tag all posts containing a specific word on title
- Order terms by count – missing terms
- Querying Advanced Custom Fields
- How to rearrange a pool of posts joined using two queries?
- wpdb update multiple row?
- Can I include get_posts in this array?
- Is there a way to add a link directly into this media query?
- Custom query Custom-Post-Types creates error
- Formatting a date/time returned from a custom $wpdb query
- Rewrite rule for query params
- Cannot get sql request from Query object?
- Hook into the Admin Dashboard and redirect users
- Displaying data from custom table
- SEO friendly query vars
- Question about of query
- Prevent versioning for .woff (font) files
- Orderby event date (if it exists) or post date (if it doesn’t) – how to reorder posts based on meta value OR date
- Modify behaviour of “s” parameter in wp_query
- OR condition not working
- Query not returning child posts for any parent post ID
- How to make MySQL search queries with quotes
- Limiting a filtered query
- Use $wpdb->get_results with filter based on array
- Add Hook for clearing transient when post is added
- Using cron for multiple queries
- Archive query not working correctly
- Custom MySQL Query for Post and Post Meta
- very slow wordpress query with default query
- Displaying popular posts
- Custom Query problem access the values
- Set posts per page for parent category and it’s all children
- Exclude sticky posts from query
- How to have more post in a page than in your home page
- Find all posts via SQL beginning with A of type B
- learn to run wpdb class
- Display old posts if no future posts exist
- Access Tables with number prefix
- how to add a read more button to my blog page?
- Rewrite Query_Var URL Parameter with Slug
- How to query different categories on index?
- How to add multiple values with add_query_arg?
- Query parsing only author ids
- 3 queries to update WordPress
- Ascending & descending posts on same page with IF statement
- Prevent executing query for wp_global_styles
- Meta Query compare with LIKE pulls similar post types: 55 and 155, and 1,155