Created
May 20, 2014 04:32
-
-
Save jfcode/842903877cc199bc6dce to your computer and use it in GitHub Desktop.
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 hwl_home_pagesize( $query ) { | |
if ( is_admin() || ! $query->is_main_query() ) | |
return; | |
if ( is_home() ) { | |
// Display only 3 posts | |
$query->set( 'posts_per_page', 3 ); | |
return; | |
} | |
if ( is_category( '3' ) ) { | |
// Display only 2 posts | |
$query->set( 'posts_per_page', 2 ); | |
return; | |
} | |
if ( is_archive() ) { | |
// Display only 5 posts | |
$query->set( 'posts_per_page', 5 ); | |
return; | |
} | |
} | |
add_action( 'pre_get_posts', 'hwl_home_pagesize', 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment