Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
List all your events alphabetically by title on the event archives page. Requires Event Espresso 4. Add the following code to your theme's functions.php file or into a site specific plugin.
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function ee_modify_query_order( $query ) {
if (
isset( $query->query_vars['post_type'] ) &&
( $query->query_vars['post_type'] == 'espresso_events' ||
( is_array( $query->query_vars['post_type'] ) &&
in_array( 'espresso_events', $query->query_vars['post_type'] )
) &&
! $query->is_singular &&
) {
remove_all_filters( 'posts_orderby' );
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
add_action( 'pre_get_posts', 'ee_modify_query_order', 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.