# Different Number of Posts on the First Blog Page

> Shows a different number of posts on the first page of the blog than on the following pages, for example 3 featured posts up front and 10 per page after that, with pagination still correct.

- Type: PHP
- Runs: Run everywhere
- Category: [Archives](https://wpide.com/library/category/archive/)
- Tags: blog, pagination, homepage
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/different-post-count-on-first-blog-page/

## Code

```php
// Number of posts on the first page of the blog.
$wpide_first_page_posts = 3;

add_action( 'pre_get_posts', function ( $query ) use ( $wpide_first_page_posts ) {
    if ( is_admin() || ! $query->is_main_query() || ! $query->is_home() ) {
        return;
    }

    $per_page = (int) get_option( 'posts_per_page' );
    $paged    = max( 1, (int) $query->get( 'paged' ) );

    if ( 1 === $paged ) {
        $query->set( 'posts_per_page', $wpide_first_page_posts );
    } else {
        $query->set( 'posts_per_page', $per_page );
        $query->set( 'offset', $wpide_first_page_posts + ( $paged - 2 ) * $per_page );
    }
} );

add_filter( 'found_posts', function ( $found, $query ) use ( $wpide_first_page_posts ) {
    if ( is_admin() || ! $query->is_main_query() || ! $query->is_home() ) {
        return $found;
    }

    $per_page = max( 1, (int) get_option( 'posts_per_page' ) );
    $pages    = 1 + (int) ceil( max( 0, $found - $wpide_first_page_posts ) / $per_page );

    if ( max( 1, (int) $query->get( 'paged' ) ) === 1 ) {
        return $pages * $wpide_first_page_posts;
    }

    return $found - $wpide_first_page_posts + $per_page;
}, 10, 2 );
```

## Notes

Later pages use the "Blog pages show at most" setting. Sticky posts are added on top of the first-page count by WordPress.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Different Number of Posts on the First Blog Page" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
