WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I change the post limit for taxonomy.php from that which is defined in the settings page?

Currently I have 10 posts displaying per page, which is fine for the blog part of my site, but I want to show all posts when the user is on taxonomy.php, is there a function that can achieve this?

share|improve this question
up vote 3 down vote accepted

Use the pre_get_posts hook to check is you are in a taxonomy term archive and change the number of posts ex:

add_action('pre_get_posts', 'change_tax_num_of_posts' );
function change_tax_num_of_posts( $wp_query ) {  
    if( is_tax() && is_main_query()) {
        $wp_query->set('posts_per_page', 5);
share|improve this answer

You can also append &posts_per_page=-1 to the query_string inside query_posts:

if ( have_posts() ): query_posts($query_string.'&posts_per_page=-1');
    while ( have_posts() ): the_post(); 


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.