I want 5 posts on my front page but 10 posts on subsequent pages (page 2, 3, ..).
In my Settings > Reading > Blog pages show at most > I have 10. But I want to show only 5 posts on the front page, so in index.php I use this :
if ( $paged <= 1 ) $posts = query_posts($query_string.'&posts_per_page=5&paged='.$paged);
Works fine except that.. In page 2, the 6th to 10th posts don’t show. As if, from page 2, WP « thought » that the front page has actually displayed the 10 first posts, not just 5.
What can I do ?
4 Answers
There is a post_limits
hook that you can use for this purpose exactly:
// in homepage show 6 posts
add_filter('post_limits', 'homepage_limits' );
function homepage_limits( $limits )
{
if(is_home() ) {
return 'LIMIT 0, 6';;
}
return $limits;
}