Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created September 23, 2011 19:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/1238229 to your computer and use it in GitHub Desktop.
Save billerickson/1238229 to your computer and use it in GitHub Desktop.
Change Posts Per Page for Event Archive
<?php
add_action( 'pre_get_posts', 'be_change_event_posts_per_page' );
/**
* Change Posts Per Page for Event Archive
*
* @author Bill Erickson
* @link http://www.billerickson.net/customize-the-wordpress-query/
* @param object $query data
*
*/
function be_change_event_posts_per_page( $query ) {
if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'event' ) ) {
$query->set( 'posts_per_page', '18' );
}
}
@rwilki
Copy link

rwilki commented Dec 4, 2014

This is a perfect solution for me, but it removes my pagination template_part. Any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment