I am using the code below to sort code as per meta_value. But in this specific Column I have dates displayed for example: 20 April 2018 or 01 June 2018
The sorting works sort of but now when I order the columns it displays it like 29 April 2018, 29 May 2018, 29 June 2018, 28 April 2018, 28 May 2018, 28 June 2018...and so and so on...
Is there a way to sort that column in a proper date format like 29 April 2018, 28 April 2018, 27 April 2018 etc....???
Code I am using as follows:
add_filter( 'manage_edit-post_sortable_columns', 'closing_sortable_columns' );
function closing_sortable_columns( $columns ) {
$columns['closing'] = 'closing';
return $columns;
}
add_action( 'pre_get_posts', 'closing_column_orderby' );
function closing_column_orderby( $query ) {
if( ! is_admin() )
return;
$orderby = $query->get( 'orderby');
if( 'closing' == $orderby ) {
$query->set('meta_key','closing');
$query->set('orderby','meta_value_num');
}
}
I tried to change meta_value_num to asc but this just mixes up everything and makes the overview even worse.