It looks like the post titles have the date format DD.MM.YYYY.
We can order the DD.MM.YYYY
titles as YYYYMMDD
with:
$query = new WP_Query( [ 'orderby' => 'wpse_mod_title ' ] );
that’s supported with this kind of plugin:
/**
* Plugin Name: WPSE-274981: Sort DD.MM.YYYY Post Titles as YYYYMMDD In WP_Query
* Desription: Supported by the wpse_mod_title orderby value
*/
add_filter( 'posts_orderby', function( $orderby, \WP_Query $q ) use ( &$wpdb )
{
$_orderby = $q->get( 'orderby' );
$_order = $q->get( 'order' );
if( 'wpse_mod_title' === $_orderby && in_array( $_order , [ 'ASC', 'DESC' ], true ) )
$orderby = " CONCAT(
SUBSTRING( {$wpdb->posts}.post_title, 7, 4 ), // Get the YYYY part
SUBSTRING( {$wpdb->posts}.post_title, 4, 2 ), // Get the MM part
SUBSTRING( {$wpdb->posts}.post_title, 1, 2 ) // Get the DD part
) {$_order} ";
return $orderby;
}, 10, 2 );
Note that this assumes the strict DD.MM.YYYY
title format, without spaces.
We might consider trimming it in SQL to make it more flexible.
I think I’m under the influence of @bonger or @thedeadmedic to write this kind of substring ordering. 😉
But consider another approaches first, like writing the titles in a sortable way, in the first place.