Skip to content

Instantly share code, notes, and snippets.

@WebBaker
Created November 20, 2012 14:37
Show Gist options
  • Save WebBaker/4118303 to your computer and use it in GitHub Desktop.
Save WebBaker/4118303 to your computer and use it in GitHub Desktop.
Adjust posts_per_page value for Tribe Events Taxonomy requests
/**
* Sets the number of posts to display on Events taxonomy pages to the value of
* EVENT_CATEGORY_POST_LIMIT (if not defined, this will be defined as 10 by
* default).
*
* @param WP_Query $query
*/
function changeEventCategoryPostsPerPage($query) {
defined('EVENT_CATEGORY_POST_LIMIT') or define('EVENT_CATEGORY_POST_LIMIT', 10);
if ($query->queried_object->taxonomy === TribeEvents::TAXONOMY)
$query->query_vars['posts_per_page'] = EVENT_CATEGORY_POST_LIMIT;
}
/**
* We are running the filter relatively late to try and counter the theme's
* own filters. You can set the number of posts that you wish to appear on
* event category pages by adding the following line before or after the
* add_filter() call:
*
* define('EVENT_CATEGORY_POST_LIMIT', 20);
*
* Where you wish upto 20 posts to display (as an example).
*/
add_filter('pre_get_posts', 'changeEventCategoryPostsPerPage', 80);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment