Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created October 21, 2019 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshfeck/1867f1f52bffbbc77a373ee0ca63925e to your computer and use it in GitHub Desktop.
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
<?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