Skip to content

Instantly share code, notes, and snippets.

@WebEndevSnippets
Created August 15, 2013 00:27
Show Gist options
  • Save WebEndevSnippets/6237177 to your computer and use it in GitHub Desktop.
Save WebEndevSnippets/6237177 to your computer and use it in GitHub Desktop.
WordPress: Category Query - Sets all categories to xx per page
add_filter( 'pre_get_posts', 'we_archive_query' );
/**
* Category Query
*
* Sets all categories to 27 per page
* @since 1.0.0
* @link http://www.billerickson.net/customize-the-wordpress-query/
*
* @param object $query
*/
function we_archive_query( $query ) {
if( $query->is_main_query() && $query->is_category() ) {
$query->set( 'posts_per_page', 24 );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment