Title: WordPress limit posts per page
Last modified: August 30, 2016

---

# WordPress limit posts per page

 *  [Arne Teubel](https://wordpress.org/support/users/arnerobot/)
 * (@arnerobot)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/wordpress-limit-posts-per-page/)
 * I have the following problem:
 * I have limited my “posts per page” on all category archive pages in the functions.
   php like this:
 *     ```
       add_filter('pre_get_posts', 'limit_category_posts');
       function limit_category_posts($query){
           if ($query->is_category) {
               $query->set('posts_per_page', 5);
           }
           if ($query->is_single()) {
               $query->set('posts_per_page', 50);
           }
           return $query;
       }
   
       add_filter('pre_get_posts', 'per_category_basis');
       function per_category_basis($query){
           if ($query->is_category) {
               if (is_category('26')){
                   $query->set('posts_per_page', 2000);
               }
               if (is_category('27')){
                   $query->set('posts_per_page', 2000);
               }
           }
           return $query;
       }
       ```
   
 * This works fine so far. But now I have a single.php – file that reads posts from
   one category and displays these in a list, like this:
 *     ```
       <?php
         query_posts(array(
             'category_name' => $autorsuche,
          ));
   
          if ( have_posts() ) :
             echo '<br /><h3>Publikationen:</h3><br /><ul class="publications">';
          endif;
   
          while ( have_posts() ) : the_post();
       ?>
   
       <li><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
       <?php the_date( 'd.m.Y', '(', ')' ); ?></li> 
   
       <?php
          endwhile;
           echo '</ul>';
           wp_reset_query();
       ?>
       ```
   
 * But this list is limited to 5 posts as well since the above filter applies as
   well. I need this to have a much larger or better no limit at all.
 * I tried a lot to alter the filter in the functions.php but didn’t find a solution
   yet.
 * Any help would be much appreciated!
 * Thank you!

Viewing 1 replies (of 1 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/wordpress-limit-posts-per-page/#post-6351044)
 * your ‘pre_get_posts’ function will not influence any custom queries.
 * more important, don’t use ‘query_posts()’ for custom queries; use ‘WP_Query()’
   instead; [http://codex.wordpress.org/Class_Reference/WP_Query](http://codex.wordpress.org/Class_Reference/WP_Query)
 * you can set the ‘posts_per_page’ within the query args; [http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters)

Viewing 1 replies (of 1 total)

The topic ‘WordPress limit posts per page’ is closed to new replies.

## Tags

 * [limit](https://wordpress.org/support/topic-tag/limit/)
 * [posts per page](https://wordpress.org/support/topic-tag/posts-per-page/)
 * [query](https://wordpress.org/support/topic-tag/query/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/alchymyth/)
 * Last activity: [10 years, 10 months ago](https://wordpress.org/support/topic/wordpress-limit-posts-per-page/#post-6351044)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
