Setting posts_per_page for taxonomy term template

Question

I have a custom taxonomy term page set up to display posts associated with that term (taxonomy-insight_type-academia.php). I figured I could use the following to limit the posts on that page based on code found here:

https://developer.wordpress.org/reference/functions/is_tax/

add_action( 'pre_get_posts', function( $query) {
    if ( $query->is_tax( 'academia', 'insight_type' ) ) {
        $query->set( 'posts_per_page', 1 );
    }
} );

I have added the term to the taxonomy but it doesn’t seem to work. I can get it to work for the taxonomy, but not the term.

Is there a way to do this?

Thanks

0
, , , , Phill 1 year 2020-07-24T22:10:23-05:00 0 Answers 57 views 0

Leave an answer

Browse
Browse