By default WordPress displays all homepage, categories, post archives, tags and custom post archives based on the number you set in the admin page. But what if you want different amounts to display for different pages? Drop this in your functions file:
function modify_num_posts($query) { if ($query->is_main_query() && $query->is_tax('series') && !is_admin()) $query->set('posts_per_page', 20); } add_action('pre_get_posts', 'modify_num_posts');
In the snippet above, I’m altering the post output for the taxonomy called “series” and I’m saying I want only 20 posts to display per page. For other kinds of pages, you can use these alternatives:
- All archive pages:
is_archive()
- Custom post type archives:
is_post_type_archive('custom-name')
- Categories:
is_category()
- Tags:
is_tag()