Problem with CPT posts being sorted by date.
-
I’m a little perplexed here. We have a custom post type for “Events” and have a meta key for the Start Date. In our functions.php file, we have this:
function respondo_events_archive_query( $query ) { global $wp_query; if ( ! is_admin() && $query->is_main_query() && (is_post_type_archive('events') || is_tax('category-event'))) { $query->set('orderby','meta_value'); $query->set('order','ASC'); $query->set('meta_key','event-date-start'); } }
The posts sort correctly according to month and day, but when there are some 2014 events thrown in the mix, it puts the 2014 events first, although they are still ordered correctly by month and day, but the 2013 events should be first.
If the order is ascending, I’m not sure why the later year events are showing up first. Thoughts on this? I hadn’t come across this before on previous sites (using a different theme).
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Problem with CPT posts being sorted by date.’ is closed to new replies.