Title: Problem with query_posts showing category posts?
Last modified: August 19, 2016

---

# Problem with query_posts showing category posts?

 *  [spicer](https://wordpress.org/support/users/spicer/)
 * (@spicer)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/problem-with-query_posts-showing-category-posts/)
 * I’ve been having a problem for weeks now with showing category posts on the category
   page? and i cant seem to figure the problem.
    When i click on my category although
   it has posts it doesnt show them, it just has a blank page.
 * My website is [http://www.nomorenoodles.co.uk](http://www.nomorenoodles.co.uk)
   
   When i try to look at my posts from the blog category all i get is a blank page:
   [http://www.nomorenoodles.co.uk/?cat=3](http://www.nomorenoodles.co.uk/?cat=3)
 * This is my code in my category-3.php file and i dont know whats wrong…
 *     ```
       <?php get_header() ?>
   
         <div id="featured" class="small">
         	<?php include(TEMPLATEPATH . '/includes/featured-small.php'); ?>
         </div>
   
       	<div id="main-top"> </div>
         <div id="main">
           <div id="maincontent">
   
       <?php
       query_posts('cat=3');
       ?>			
   
       			<div class="clearboth"></div>
       			<div class="navigation">
       				<div class="alignleft"><?php next_posts_link('&laquo; Previous Posts') ?></div>
       				<div class="alignright"><?php previous_posts_link('Next Posts &raquo;') ?></div>
       			</div>
           </div>
   
       	<?php get_sidebar() ?>
           <div class="clearboth"></div>
         </div>
   
       <?php get_footer() ?>
       ```
   
 * Can anyone help?

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

 *  [SimonJ](https://wordpress.org/support/users/simonj/)
 * (@simonj)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/problem-with-query_posts-showing-category-posts/#post-952118)
 * You don’t have a loop in your code…
 *     ```
       <?php
       query_posts('cat=3');
       ?>
   
       missing--><?php if (have_posts()) : while (have_posts()) : the_post(); ?>		
   
       missing--> ---YOUR STUFF (title, permalink, author, date, etc.---
   
       missing--><?php endwhile; ?>
       ```
   
 * Look in your other files, like index.php, to see how to buid a loop…
 * S.
 *  [Doodlebee](https://wordpress.org/support/users/doodlebee/)
 * (@doodlebee)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/problem-with-query_posts-showing-category-posts/#post-952121)
 * Also, if you’re file is called “category-3.php” you don’t need the query – it’ll
   already pull that template for that category.
 *  Thread Starter [spicer](https://wordpress.org/support/users/spicer/)
 * (@spicer)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/problem-with-query_posts-showing-category-posts/#post-952253)
 * I didnt think i needed the query but because when i clicked on the category none
   of the posts show up i thought there must be a problem.
    I read that when category.
   php doesnt exist which it doesnt it pulls the template from index.php and when
   i clicked on my category no posts were shown so i thought it must need a query.
 *  [Doodlebee](https://wordpress.org/support/users/doodlebee/)
 * (@doodlebee)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/problem-with-query_posts-showing-category-posts/#post-952270)
 * This’ll help you a bit on that question:
 * [Template Heirarchy](http://codex.wordpress.org/Templates_Hierarchy)
 * WordPress actually looks to use index.php *last*. It’ll first look for the specific
   category ID, then a general category file, *then* index.php.
 * Just so you know 😉
 * If it didn’t pull the post – well my guess is the solution mentioned above. If
   you don’t have a Loop, nothing’s gonna show.
 *  Thread Starter [spicer](https://wordpress.org/support/users/spicer/)
 * (@spicer)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/problem-with-query_posts-showing-category-posts/#post-952393)
 * Thanks for your comments.
 * My new category-3.php looks like this but it is still not pulling the posts as
   you can see from [http://www.nomorenoodles.co.uk/?cat=3](http://www.nomorenoodles.co.uk/?cat=3)
 *     ```
       <?php get_header() ?>
   
         <div id="featured" class="small">
         	<?php include(TEMPLATEPATH . '/includes/featured-small.php'); ?>
         </div>
   
       	<div id="main-top"> </div>
         <div id="main">
           <div id="maincontent">
   
       <?php
       query_posts('cat=3');
       ?>
               <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
       				<?php if($counter==1){
       				  $counter++;
       				} else { ?>
       					<div class="postwrapper clearfix">
       						<div class="bubble"><?php comments_popup_link('0', '1', '%'); ?></div>
       						<h1 class="post"><a id="post-<?php the_ID(); ?>" href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a> <?php edit_post_link('Edit'); ?></h1>
       						<div class="posted">Posted on <span><?php the_time('l, F j, Y'); ?></span> in <span><?php the_category(', ') ?></span></div>
       						<?php the_content('Continue Reading'); ?>
   
       						<?php if (function_exists('the_tags')) { ?>
       					  	<?php the_tags('<div class="tags">Tags: ', ', ', '</div>'); ?>
       						<?php } ?>
       						</div>
       				<?php $counter++; } ?>
   
       		<?php endwhile; ?>
   
       		<?php else : ?>
       			<h1>Not Found</h1>
       			<p>Sorry, but you are looking for something that isn't here.</p>
       			<?php include (TEMPLATEPATH . "/searchform.php"); ?>
       			<div class="postmeta"></div>
       		<?php endif; ?>
       			<div class="clearboth"></div>
       			<div class="navigation">
       				<div class="alignleft"><?php next_posts_link('&laquo; Previous Posts') ?></div>
       				<div class="alignright"><?php previous_posts_link('Next Posts &raquo;') ?></div>
       			</div>
           </div>
   
       	<?php get_sidebar() ?>
           <div class="clearboth"></div>
         </div>
   
       <?php get_footer() ?>
       ```
   
 * I just dont know what the problem is, so annoying and just about given up im 
   just typing news posts straight into the page now.
 *  [Doodlebee](https://wordpress.org/support/users/doodlebee/)
 * (@doodlebee)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/problem-with-query_posts-showing-category-posts/#post-952406)
 * well, again, you don’t need the query. What’s the counter for? And you’re telling
   the site that if there’s posts, and while you have posts to do nothing, except
   as 1 to whatever number you’re counting. You don’t even have that echoed out.
   You don’t have the display for any actual content because you’re telling it to*
   not* display a post if it finds one, and if it does find one, then to display
   it (which it won’t, because if it finds one, it won’t display it.)
 * What in the world are you trying to do?
 *  Thread Starter [spicer](https://wordpress.org/support/users/spicer/)
 * (@spicer)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/problem-with-query_posts-showing-category-posts/#post-952407)
 * As you can see I’m very new to programming. All i am trying to do is get the 
   category page to show the posts from that category.
 *  [Doodlebee](https://wordpress.org/support/users/doodlebee/)
 * (@doodlebee)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/problem-with-query_posts-showing-category-posts/#post-952416)
 * Well, like I said, as long as the name of your file is “category.php” or “category-
   X.php” (where X is the ID of the category), then it’ll show. You don’t need the
   query – it already does it.
 * Look at the default template as an example.
 *  [saurabhdidwania](https://wordpress.org/support/users/saurabhdidwania/)
 * (@saurabhdidwania)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/problem-with-query_posts-showing-category-posts/#post-952597)
 * i was facing similar problem for my blog [http://www.crazybulb.com](http://www.crazybulb.com)
   
   when i used to click on category, i used to get a blank page.
 * I faced this problem after I transferred my blog to a new domain.
 * I diagnosed the problem to archive.php and archives.php file. both the files 
   were blank. so I downloaded my theme folder fresh from internet. copied the two
   files into my active theme’s folder and my categories started showing post in
   [http://www.crazybulb.com](http://www.crazybulb.com)

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

The topic ‘Problem with query_posts showing category posts?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 9 replies
 * 4 participants
 * Last reply from: [saurabhdidwania](https://wordpress.org/support/users/saurabhdidwania/)
 * Last activity: [16 years, 6 months ago](https://wordpress.org/support/topic/problem-with-query_posts-showing-category-posts/#post-952597)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
