Skip to content

Instantly share code, notes, and snippets.

@GaryJones
Forked from billerickson/gist:1547518
Created January 1, 2012 16:45
Show Gist options
  • Save GaryJones/1547745 to your computer and use it in GitHub Desktop.
Save GaryJones/1547745 to your computer and use it in GitHub Desktop.
Increase post count to 20 - Right Way
<?php
add_action( 'pre_get_posts', 'be_increase_posts_on_quotes_archive' );
/**
* Increase posts on quotes archive.
*
* @author Bill Erickson
* @link http://www.billerickson.net/customize-the-wordpress-query/
*
* @param WP_Query $query
*/
function be_increase_posts_on_quotes_archive( WP_Query $query ) {
if( $query->is_main_query() && $query->is_post_type_archive( 'quotes' ) && ! is_admin() )
$query->set( 'posts_per_page', '20' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment