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
- Trouble with serialized metadata
- Function is printing twice – any suggestions?
- Query on a repeater date (acf)
- Adding an option to post editor to show a site disclaimer or message
- Display/Filter post using if else statement
- How to sort WP_Post Object array by object field in php?
- Search results for ACF data
- Multisite how to display merged posts from two sites and sort by latest date?
- Saving canvas generated image when saving post causes 404 error
- Query prints posts without specific categories
- Private post caught in endless redirect loop
- Show posts from WP Custom Post Type selected from a field in a metabox
- How to retrieve all meta data directly from the $post object? Such as $post->related_topics?
- What is proper filter or hook action to add data to the $post object?
- Display specific posts based on an ID of another post
- Numbered Pagination Showing The Same Posts After Altering WP_Query
- Order by meta_key field in WordPress not meta_value field value
- a WordPress connected to 2 database
- How to display particular set of wordpress post on a webpage?
- Need to display a Jan 1st post as the site’s front page on Jan 1st, and Jan 2nd post as front page on Jan 2nd etc
- query posts with selected post ids first
- Change URL of previous posts and next posts link in WordPress
- Query against multiple locations within single custom post type post
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- How to invoke a HTML custom button based on a HTML dropdownlist menu
- How to create page with post content in it?
- Blogposting Schema & Structured Data without plugin
- Order posts inside bootstrap card columns
- long-title posts do not want published
- Automatically select template based on query string for New Posts
- How to remove a post from results by ID after query?
- Using a meta_value or postdate to to query and orderby
- Exclude posts in home slider from sections
- Display Updated Date Instead of Published Date
- Is there a way to save different data when USER interacts with the same POST?
- Mix post date with post meta value using WP_Query
- How to use two query result together in one loop
- Add postmeta to all blog posts
- show loop id post , only first id can read
- When working with a post, almost all wp_postmeta are deleted
- WP_Query that targets all categories
- Counting Posts by Category
- Fill the exclude array() in get_posts()
- show image gallery in archives or category page
- Page with Category Returning 1
- The first post appears twice
- filter posts based on menu_order
- Bulk Post update_post_meta
- Re-order Category Meta-data
- Show 5 posts and than 3 posts offset with pagination
- Double loop output
- Change archive results based on GET request
- wp_query args with relation
- How to hide meta from search result only on pages?
- Ajaxify Post Sort
- How do I display posts ordered by a date custom field?
- Override wp_link_pages pagebreak with filter
- Get 5 most recent categories
- Loop through all posts showing duplicates
- Grab meta data before post is saved
- WP_Query extended with AJAX
- Manipulate query to show specific post
- Wp_query loop is not working as it should
- Get current user, change users post status to published
- Show all posts from the tags without having to set all of them
- How to fetch posts that are stored in the different table than the default table (wp_posts)?
- Meta key in wp_query bug?