# Posts per Page on Author and Date Archives

> Sets how many posts appear on author and date (year, month, day) archives, independent of the main blog setting.

- Type: PHP
- Runs: Run everywhere
- Category: [Archives](https://wpide.com/library/category/archive/)
- Tags: pagination, authors, dates
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/posts-per-page-author-date-archives/

## Code

```php
// Posts per page on author archives and date archives.
$wpide_author_per_page = 20;
$wpide_date_per_page   = 30;

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

    if ( $query->is_author() ) {
        $query->set( 'posts_per_page', (int) $wpide_author_per_page );
    } elseif ( $query->is_date() ) {
        $query->set( 'posts_per_page', (int) $wpide_date_per_page );
    }
} );
```

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Posts per Page on Author and Date Archives" 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/
