Title: showposts=-1 crashing loop
Last modified: August 19, 2016

---

# showposts=-1 crashing loop

 *  [skytribe](https://wordpress.org/support/users/skytribe/)
 * (@skytribe)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/showposts-1-crashing-loop/)
 * Since I upgraded to 2.8.4 I seem to be having a problem with a page that creates
   an archive listing by using a query using showposts=-1&cat=3. It seems to be 
   an interaction with some of the plugins, SEO and wp-polls but I can’t work out
   what. It seems to be something with running to the end of the posts as if is 
   use 500 instead of -1 it works fine but if I use 1000 it fails in the same way
   as with -1. Any help would be appreciated.
 * Here is the code:
 *     ```
       <?php get_header(); ?>
   
       	<div id="content" class="narrowcolumn">
   
           <?php if (have_posts()) : ?>
           	<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
   
       		<?php
       		$current_month = get_the_time('m');
       		$current_year = get_the_time('Y');
   
       		if ($current_month != date('m') || $current_year != date('Y')) {
       			/* This is an archive not current month*/
       			echo '<h2 class="pagetitle">News Archive for ' . get_the_time('F, Y') . '</h2>';
       		} else {
       			echo '<h2 class="pagetitle">In the News This Month:</h2>';
       			$current_month = date('m');
       			$current_year = date('Y');
       		}
   
       		query_posts("cat=3&year=$current_year&monthnum=$current_month&order=DESC&showposts=-1");	
   
       		?>
   
       		<ul>
       		<?php while (have_posts()) : the_post(); ?>
   
                           <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_time('d/m/Y') ?> - <?php the_title(); ?></a></li>
   
       		<?php endwhile; ?>
   
       		</ul>
   
       <h2>News Archive:</h2>
       <ul>
       <?php
       		$ArchYear=0;
       		$ArchMonth=0;
       		//echo '<li>hello</li>';
       		//query_posts("cat=3");
       		//$archive_query = new WP_Query('showposts=-1&cat=3');
       		$archive_query = new WP_Query;
       		$archive_query->query('showposts=500&cat=3');
       		while ($archive_query->have_posts()) : $archive_query->the_post();
       			//echo '<li>' . get_the_time('m') . '</li>';
   
       			if (get_the_time('Y') != $ArchYear) {
       				if ($ArchYear != 0 ) {
       					echo '</ul></li>';
       				}
       				echo '<li>' . get_the_time('Y') . '<ul>';
       				$ArchYear = get_the_time('Y');
       			}
       			if (get_the_time('m') != $ArchMonth) {
       				$ArchMonth = get_the_time('m');
       				echo '<li><a href="/news/' . $ArchYear . '/' . $ArchMonth . '">' . date('F', mktime(0,0,0,$ArchMonth,1)) . '</a></li>';
       			}
   
       		endwhile;
       ?>
       </ul>
   
       	<?php else : ?>
   
       		<h2 class="center">Not Found</h2>
       		<?php include (TEMPLATEPATH . '/searchform.php'); ?>
   
       	<?php endif; ?>
   
       	</div>
   
       <?php get_sidebar('news'); ?>
   
       <?php get_footer(); ?>
       ```
   

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

 *  [doc4](https://wordpress.org/support/users/doc4/)
 * (@doc4)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/showposts-1-crashing-loop/#post-1204537)
 * skytribe,
 * I’ve never seen the use of showposts=-1 can you explain why you would do this?
   Thanks
 *  Thread Starter [skytribe](https://wordpress.org/support/users/skytribe/)
 * (@skytribe)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/showposts-1-crashing-loop/#post-1204544)
 * Hi thanks
 * I want the query to return all the posts in the category 3 (our news category)
   so I can then run through them creating a list of years and months with links
   to those archives so the user can quickly get to them. If you go to [http://www.xcmag.com/category/news/](http://www.xcmag.com/category/news/)
   you can see it in action, but at the moment in is only an archive to the latest
   500 posts because of the above problem.
 * Thanks

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

The topic ‘showposts=-1 crashing loop’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [skytribe](https://wordpress.org/support/users/skytribe/)
 * Last activity: [16 years, 8 months ago](https://wordpress.org/support/topic/showposts-1-crashing-loop/#post-1204544)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
