You can use pre_get_posts
and is_category
conditional tags to set posts_per_page
to 10 for category pages.
Here is a working exacmple
function wpse_posts_cat_pages( $query ) {
if ( $query->is_category() && $query->is_main_query() ) {
$query->set( 'posts_per_page', '10' );
}
}
add_action( 'pre_get_posts', 'wpse_posts_cat_pages' );
What this code do:
- Check if it is the main query
$query->is_main_query()
and if the page is a category (category.php) page$query->is_category()
, and if both of these are valid, the amount of posts are limited to 10, no matter what is set in the back end