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.
Opens WPIDE on
Code
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 add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.