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.