Last active
August 29, 2015 14:08
-
-
Save codehooligans/d5f9877a742fe236220e to your computer and use it in GitHub Desktop.
Codehooligans.com: Limit Posts per Archive Page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function limit_posts_per_archive_page( $query ) { | |
// If running within wp_admin or NOT the main $wp_query abort! | |
if ( is_admin() || ! $query->is_main_query() ) return; | |
if ( $query->is_category() ) { | |
$query->set('posts_per_archive_page', 8); | |
} elseif ( $query->is_search() ) { | |
$query->set('posts_per_archive_page', 10); | |
} | |
} | |
add_action('pre_get_posts', 'limit_posts_per_archive_page'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment