Display certain amount of posts on taxonomy archive page

Maybe a very quick and (simplified)dirty way I show here, but would this function not solve it without the need to make changes for/in the templates?
(Yes I know I also make queries in my templates but wanted to help out before leaving office)

function wpse214084_max_post_queries( $query ) {

   if(is_tax('genre')){ // change genre into your taxonomy or leave out for all
     // show 20 posts
     $query->set('posts_per_page', 20);
   }
}
add_action( 'pre_get_posts', 'wpse214084_max_post_queries' );

FYI: Maybe you take a look at
pre_get_postsin
the codex and also at
is_tax.
What you probably where/am looking for is query
posts

post_per_page.

I hope this helps you out or at least gives some guidelines.

Leave a Comment