# Posts per Page on Category and Tag Archives

> Shows 20 posts on category, tag and custom taxonomy archives without changing the number on the blog page.

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

## Code

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

    if ( $query->is_category() || $query->is_tag() || $query->is_tax() ) {
        $query->set( 'posts_per_page', 20 );
    }
} );
```

## How to use it

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