How do I display different number of posts on the home page and archive pages, the archive pages can use the value set in the admin, but I want a custom number of posts to be displayed on the home page with pagination. Thanks.


This can be done with a very short plugin.

function posts_on_home_page( $posts_per_page ) {
    if ( is_home() )
        return 5;
    return $posts_per_page;

add_filter( 'pre_option_posts_per_page', 'posts_on_home_page' );

This is actually pretty close to the Codex example for pre_option_(option_name).

  • But is there a way to distinguish home.com from home.com/page/2/ – bodesam Oct 29 '14 at 22:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.