I want to show 30 posts for category 9 and 10 posts for all other categories. By searching the forum I’ve found this code which I edited a little but it somehow doesn’t work, do you have an idea why?
add_action( 'pre_get_posts', 'tu_change_posts_per_page', 1 );
function tu_change_posts_per_page( $query ) {
if ( ( ! is_main_query() && ! is_category('9') ) || is_admin() ) {
return;
}
if ( ! $query->is_paged && ! is_category('9') ) {
$query->set( 'posts_per_page', 30 );
}
}