Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created June 24, 2019 17:22
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/00fe1a7b8bd284b4d81520bc39540c12 to your computer and use it in GitHub Desktop.
Save joshfeck/00fe1a7b8bd284b4d81520bc39540c12 to your computer and use it in GitHub Desktop.
Changes Event Espresso venues sort order to order by title (name). Also, removes pagination for venue post type archives.
<?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_venue_archive_by_title');
function order_venue_archive_by_title($query) {
if ( $query->is_archive &&
isset($query->query['post_type']) &&
$query->query['post_type']== 'espresso_venues' )
{
$query->set('orderby', 'title');
$query->set('order', 'ASC');
// remove pagination
$query->set('posts_per_page', -1);
}
return $query;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment