2018 Date Sorting Not Working
-
I am using CMB2 fields for my custom post type event plugin. I am having a problem with the new posts showing ascending from year 2016, 2017 and then 2018. It will sort by month and day but not by year for some odd reason now. Anyone know what I am doing wrong.
Here is the pre_get_posts query I have to customize the order:
add_action( 'pre_get_posts', 'dc_sort_date' ); function dc_sort_dates( $query ) { if ( $query->is_main_query() && !is_admin() ) { if ( $query->is_tax() || $query->is_post_type_archive('date_hub') ) { $query->set( 'posts_per_page', 6 ); $query->set( 'meta_key', 'dc_datehub_dc_date' ); $query->set( 'orderby', array('meta_value' => 'DESC')); } } }
This is my date field:
array( 'name' => __( 'Event Date', 'date_hub' ), 'id' => $prefix . 'dc_date', 'desc' => 'Date - NOTE: Must Have to Display!', 'type' => 'text_date', ),
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘2018 Date Sorting Not Working’ is closed to new replies.