Created
October 21, 2019 17:36
-
-
Save joshfeck/1867f1f52bffbbc77a373ee0ca63925e to your computer and use it in GitHub Desktop.
Set /events/ archive to use WordPress defaults for posts orderby. Event Espresso 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file | |
add_filter('pre_get_posts', 'order_event_archive_by_wp_default'); | |
function order_event_archive_by_wp_default($query) { | |
if ( $query->is_archive && | |
isset($query->query['post_type']) && | |
$query->query['post_type'] == 'espresso_events') | |
{ | |
$CPT_Event_Strategy = EE_Registry::instance()->load_core('EE_CPT_Event_Strategy'); | |
remove_filter('posts_orderby', array($CPT_Event_Strategy, 'posts_orderby'), 1); | |
} | |
return $query; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment