I have the following function in my functions.php, that changes the number of posts displayed per page in the custom post type archive page. How can I also target the corresponding taxonomy page(taxonomy-case.php)? Is there something similar to "is_post_type_taxonomy"?
// Post number limits
function my_cptui_change_posts_per_page( $query ) {
if ( is_admin() || ! $query->is_main_query() ) {
return;
}
if ( is_post_type_archive( 'case' ) ) {
$query->set( 'posts_per_page', 8 );
}
}
add_filter( 'pre_get_posts', 'my_cptui_change_posts_per_page' );
Add below code inside your function and check if it's working. Don't forget to replace your category with your taxonomy name.
if (is_tax( 'your-category' ) ) {
$query->set( 'posts_per_page', 8 );
}