Title: Posts per Page
Last modified: August 22, 2016

---

# Posts per Page

 *  [timondeks](https://wordpress.org/support/users/timondeks/)
 * (@timondeks)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/posts-per-page-18/)
 * I’m trying to get the below page template to show all posts from all categories.
   I tried setting ‘posts to page’ to -1 but no such luck. Am I missing something
   else?
 *     ```
       <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
       			      $the_query = new WP_Query( array (  'posts_per_page' => 1, 'category__in' => $categories, 'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1)) ); $i= 2; ?>
       			<?php while ( $the_query->have_posts() ) : $the_query->the_post(); 	$id = get_the_ID();  ?>
       			<?php if ($i % 2 == 0) { echo '<div class="centered inner"><div class="whole-post">'; }
       				  else { echo '<div class="blue-content color-grey"><div class="centered inner"><div class="whole-post">'; } ?>
       				  <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
       				 <div class="post-info">Posted <?php the_time('F jS, Y'); ?><?php /* &nbsp;|&nbsp; Author: <?php the_author();  */?></div>
       				 <div class="post-content"><?php the_content(); ?></div>
       			<?php if ($i % 2 == 0) { echo '</div></div>'; } else { echo '</div></div></div>'; } ?>
       			<?php $i++; ?>
       			<?php endwhile; ?>
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [timondeks](https://wordpress.org/support/users/timondeks/)
 * (@timondeks)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/posts-per-page-18/#post-5354005)
 * Anyone? I could use a default loop but I’m unsure of how I would set alternate
   background colors for each second post.
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/posts-per-page-18/#post-5354006)
 * your posted code shows the `'posts_per_page'` parameter set to `1`
 * alternatively to using `-1` you could try to use the `nopaging` parameter and
   set it to `true` (untested)
 * > `nopaging` (boolean) – show all posts or use pagination. Default value is ‘
   > false’, use paging.
 * [http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters)
 *  Thread Starter [timondeks](https://wordpress.org/support/users/timondeks/)
 * (@timondeks)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/posts-per-page-18/#post-5354023)
 * Thanks for the reply Alchymyth. I’m afraid my knowledge of WordPress php is very
   thin on the ground. Where/how would I add the `nopaging` parameter to the above?
 *  Thread Starter [timondeks](https://wordpress.org/support/users/timondeks/)
 * (@timondeks)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/posts-per-page-18/#post-5354049)
 * Can anyone else advise on this? I could create a new paginated page using a default
   loop but am unsure of how to set alternate backgrounds for each post.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Posts per Page’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [timondeks](https://wordpress.org/support/users/timondeks/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/posts-per-page-18/#post-5354049)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
