I have a taxonomy archive page where I display everything under the term 'techno' I want to be able to limit this to 20 posts to a page until it paginates. At the moment it displays 10 on one page and then 10 on another. This works fine on my main page where I give the posts per page limit to 20. Can anyone see why? Here is my code



Template Name: Genre


//Protect against arbitrary paged values
$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1; 


$object = get_queried_object();

$taxonomy = "genre"; // can be category, post_tag, or custom taxonomy name

// Using Term Slug
$term_slug = $object->slug;
$term = get_term_by('slug', $term_slug, $taxonomy);

// Fetch the count
$number = $term->count / 20;

<header class="intro-archive">
        <div class="intro-body">
            <div class="container">
                <div class="row">
                    <div class="col-md-8 col-md-offset-2">
                        <h1 class="brand-heading"><?php echo $object->name; ?></h1>

                        <p class="intro-text">An archive of all the <?php echo $object->name; ?> posted on the site</p><a class="btn btn-circle page-scroll fa fa-angle-double-down animated" href="#latest" style="font-size:54px;"></a>
    </header><!-- About Section -->

    <section class="container content-section text-center" id="latest">

        $j = 0;

         if ( have_posts() ) : while ( have_posts() ) : the_post(); // standard WordPress loop.

              $thumb_id = get_post_thumbnail_id();
              $thumb_url_array = wp_get_attachment_image_src($thumb_id, '370x250' );
              $thumb_url = $thumb_url_array[0];

              // Grab the artist ID from the post meta
              $artist = get_post_meta(get_the_ID(), '_artist');

              // seperate each artist id
              $explodeArray = array_filter(explode(' ', $artist[0]));

              $arrayLength = count($explodeArray);

              $i = 0;

              // If there is more than one artist attached to song loop through
              if ($arrayLength > 1) {
                foreach ($explodeArray as $array) {
                  $artist_meta[$i] = get_the_title($array);
              } else {
                $artist_name = get_the_title($explodeArray[0]);

              // If the current counter dividied by 4 leaves no remainder add a row
              // This splits our archive into rows with 4 elements in
              if($j % 4 == 0) { ?> 

              <div class="row ">

              <?php } ?>

                  <div class="col-md-3 col-sm-12" style="margin-top:100px;">
                        <div class="ih-item square effect3 bottom_to_top">
                            <a href="<?php the_permalink(); ?>">
                                <div class="img">
                                    <img alt="" class="image-responsive" src="<?php echo $thumb_url ?>">
                                <div class="info">
                                    <h3><?php if ($artist_meta) { foreach($artist_meta as $meta) { echo $meta; echo '<br />'; } } else { echo $artist_name; } ?></h3>
                                    <p><?php the_title(); ?></p>


                if ( $j != 0 && $j % 4 == 0 ) { ?>


                endwhile; endif;
               <div class="col-md-12">
                  <?php dem_pagination($number); ?>
        </section><!-- Footer -->

    <?php get_footer(); ?>   

2 Answers 2


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.


i back @Charles answer, along with that another workaround is to create new object of WP_Query class, and use that object's loop instead of default loop,

Dont forget to use


to get the current taxanomy and load it into WP_Query's object parameters. with that you can use posts_per_page.

more details here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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