I think the sort is either alphabetical or numerical. There is no API way to provide more elaborate sorting rules to the query and messing with SQL for it would be likely impractical.
Since you are retrieving complete set of posts (don’t have to worry about pagination) the easiest way would be:
- Request no sort from query.
- Re–sort
$the_query->posts
set of results with PHP code before starting the loop for output.
Related Posts:
- How can I sort posts by the date and a custom meta field?
- WP_Query sort by meta_value_num or date
- Update all posts automatically when using post_meta
- Better post meta efficiency?
- Change post format using custom field
- Sanitizing `wp_editor();` Values for Database, Edit, and Display
- What Is meta_id In wp_postmeta?
- Add custom field automatically (add_post_meta) with value based on number of words of article
- Automatic value for custom fields for posts
- WP_Query orderby not working with meta_value_num and menu_order
- is there a way to show the the post title after the image?
- How do I correctly set up a WP-Query to only show upcoming event-posts?
- Query Posts With Over 1000 Views
- Cannot retrieve a custom RSS field from posts
- Query Posts by Custom Field
- Customize rel=canonical tag for single blog post
- How to I retrieve the ID from the Posts page?
- if in category but only with post meta
- wp_query with ajax
- Saving Post Data in Another Database
- Add multiple meta keys to a post at once
- WP_Query custom field pass the post id
- saving/reading custom field value does not work – no value gets POSTed
- Override WordPress core post-template.php block template
- Post meta not working
- How do you update post date (year only) in a separate custom field?
- How to get value of a selected option from select tag and use it in WP_query to filter posts?
- Show posts between two Custom Fields date
- WP Query between posts custom fields [duplicate]
- Order posts by separate menu order for different sub-categories
- How enter custom post meta or custom field on box post list archive page?
- WP_query sort by custom meta_key “price”
- Image inside the content is replaced with featured image from my older post
- Should we trust the post globals?
- Add a checkbox to post screen that adds a class to the title
- Export WordPress Posts and Meta Information in CSV format
- Querying post from a multisite network
- How to know if get_posts() failed?
- Show related posts by category but ignore one category
- post__in for get_posts with a dynamic array
- I am trying to create a simple frontend form for posting
- HTML code in Custom field
- Post content being duplicated by the_content();
- Guest Author – How to modify my custom function code if the guest author URL will follow a particular pattern/format?
- Specific loop in Shortcode
- How to add padding between posts
- Working Bootstrap Carousel Conversion to WP – Technical Questions
- Search widget breaks when using multiple loops?
- Add few specific post ids to wp_query
- How can I make existing custom fields easier to edit/add in my theme?
- WP_Query posts_per_page ignored
- wp_query ‘s’ parameter does not work with custom post type
- Understanding and using metaboxes in posts
- WP Query – duplicated posts once including tags in search results
- how to get posts ids inside pre_get_posts filter?
- How do I use WP_Query to get a range of posts with custom fields that have numbers with letters in them?
- recent posts for different categories
- Update Post Meta for a logged in user
- Change post order random through out the entire WordPress
- Setup a custom dynamic post
- Anyway to grab author name and featured image in an embeded in inital array of posts outside of loop?
- Removing noindex posts from wp_query
- Custom Posts Query and meta_query Sort Order
- Calling Different Custom Post Timestamps in a table
- Exclude the first ‘n’ number of posts of a tag from home page?
- wp_posts table: safely remove unused columns to save database storage
- Using wp_list_pages() after calling query_posts()
- Why are my paginated posts always returning the same results?
- Inner join overrides Advanced Custom Fields plugin’s get_field [closed]
- Is there any way to tell when wp_postmeta has been updated?
- Query posts by Author and/or by Tag
- WP_Query: getting posts where custom field exists
- Migrate posts from category and sub-category via SQL
- Display post number by category
- Output Post with ACF Fields into other Post
- Exclude some posts from displaying in wp_query based on some condition
- When sending a newsletter -not with wordpress- the server has 100% cpu [closed]
- WP_Query get posts in custom database table [duplicate]
- How to save template data into wp_post table (post_content column)
- WP query taxonomy optimization
- Custom Fields – How to get the list of a specific active widget each time it rendered
- Displaying all posts from other sites on the network on one site
- Multisite how to display merged posts from two sites and sort by latest date?
- Saving canvas generated image when saving post causes 404 error
- Blogposting Schema & Structured Data without plugin
- Using a meta_value or postdate to to query and orderby
- Exclude posts in home slider from sections
- Ajaxify Post Sort
- Grab meta data before post is saved
- Get current user, change users post status to published
- Get query result according to merged array
- Add custom class to existing menu items from custom meta
- How to show the posts list into a static page? Problems to use the loop into a static page
- Displaying Results From Custom Taxonomy Query
- Multiple loops on a Search result page?
- How can I create a menu items from meta box based on users input
- WP_Query: Fetch posts that are in (category1 and not in category2), OR posts that are not in cagegory1
- How do I show the post title if an advanced custom field hasn’t been used?
- How add class the_content();?
- Site ‘Categories’: save an admin global setting with post metadata [closed]