On post insert/update, set the post’s menu_order
as the maximum of the numeric MMDD
values of original_date
and featured_date
. Maybe set the menu order in the format 1MMDD
to avoid a leading zero.
Then we can order the custom type posts by the menu order very fast with:
WP_Query( [
'post_type' => 'custom_post_type',
'orderby' => 'menu_order',
'order' => 'DESC'
] );
where menu_order
is a int(11)
column in the posts table.
If not all of the custom type posts have these custom dates, group them e.g. by a custom taxonomy, to use in your WP_Query
. Maybe one could instead look for posts with non-zero menu order.
Related Posts:
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- Wp_redirect and sending variables
- How do I get posts that have a thumbnail in WP_Query?
- Multiple WP_Query loops with Pagination
- how does $wpdb differ to WP_Query?
- WP_Query – filter or directly?
- WP_Query with checkbox meta_query
- IP address character limit
- What is the most efficient way of querying posts based on visits and date for current day?
- How can I save an array from a random post sequence for later use?
- Does WordPress generate an automatic page for post formats?
- Why is WP-Query spelled like it is?
- How to add custom query filters in WP_User_Query
- How to order category.php loop by ‘meta_value’?
- Searching user meta using WP_User_Query
- Which custom query am I in and how can I access its properties & methods?
- Pagination not working Search posts
- Does using a custom query_var create a security hole?
- How to sort posts in admin by titles with dd.mm.yyyy format?
- Why I can’t get old posts instead of recent with WP_Query?
- How get posts from a subcategory of a category by name?
- Date query not inclusive despite parameter being true
- WP_Query or get_posts?
- How to display the number of articles published per user
- How do you query wordpress posts using a math formula between multiple meta field values?
- Change default ordering of taxonomy terms – pre_get_terms
- Ordering Posts Type A by Custom Fields of related Post Type B
- Query Posts depends on custom field inside repeater field using acf
- Exclude old events from WP_Query with date saved in a `meta_key`
- WP_Query arguments to fetch custom post type posts which are in certain category?
- WP_Query loop within WP_Query loop
- current_post not working – give me -1 for every post
- How to fetch only media that was already attached to a post/page?
- (Solved) WP_Query ($ args) -> How to sort letters and numbers within the same array
- WP_Query won’t retrieve raw HTML?
- Remove a specific category ID from related post
- Order posts by taxonomy count
- Query all published post AND attachment with specific mime type
- Any number in meta key (wp query)
- Custom Metabox data slow query on Admin init
- WP_QUERY to display woocommerce products whose author IS the logged in user
- Order by summing multiple values
- Understanding the orderby in WP_Query?
- Need Help For WPQuery
- When variable value have space between word, doesnt show any result WP_Query
- How to list custom fields as headers and list all pages sharing that custom field under it?
- Posts published last 10 minutes
- Make meta query treat meta_value as 1 or 0
- Getting additional columns from sql
- get all posts associated with a custom taxonomy
- WordPress query posts with multiple post_meta data
- Assign custom parameter to each post in query
- Exclude current post from an array of posts?
- complex get_posts() query to select child pages
- How to add $args to any running wp_query from function.php?
- How to remove only the latest sticky post from the loop
- Query posts using less than
- var_dump of WP_Query object is not empty, while .have_posts() return false
- How to view all posts of current day as default in admin
- How to show list of posts with custom field value (a date) that are coming soon
- Widget only in first post
- Using WHERE on a WP_Query
- WP_Query meta compare must include ALL array values
- How to sort queried pages by an array of page ids?
- How to query for a page, get data, then query for child pages of that page
- How can I change the term “Published” next to # of posts published on WordPress dashboard All Posts page?
- Multiple loops breaking side bar
- $post in wp_query?
- meta_query weird behaviour, static int will work, but not user data
- How can I return only IDs from the `posts` REST endpoint?
- search through “product title” using WP_Query?
- Excluding posts from search results page with meta query not working
- Counting instances of words in the results of a post query
- Query posts by post type, author and post meta
- WP_query pagination on frontpage
- WP Query by 4 different taxonomies
- Order by value of Custom Field using url string
- How to set meta_query if get_post_meta returns nested array for that key? [duplicate]
- Is the ‘parse_query’ filter still valid to change filtered content on admin list view?
- I removed the “wp_rm_logs” table and am constantly getting this error
- How to set selected attribute on option after filter query?
- WP_Query returns empty if meta_query has more than 7 values
- query.php – multiple is_category functions
- Custom query with post_class filter using current_post not working
- Overwriting auto-appended NOT IN query in WP_Query
- posts_per_page not returning correct number of posts
- query_posts with sorting on a custom datestamp
- Conditionals in WP_Query
- Why WP_Query in functions.php is not working when get_posts works?
- Next / previous posts link doesn’t show up with Posts 2 Posts
- Loop the posts between two dates selected using jquery datepicker
- query by meta value then date and not empty meta value
- Issue with sorting by post date and custom post type
- Is it possible to use WP Query to orderby custom meta value and custom taxonomy?
- Display all custom meta field values from the database using ACF Repeater
- wordpress sorting using array merge by price in ascending order but price with 0 must be show last
- Remove divs and spans from post content
- Can’t get LIKE to work with wp_query [closed]
- Get all user with both meta_value
- Use meta query only 3 or more results?