WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Really rusty on the wordpress front.

I am using custom permalinks /%category%/%postname%/ as well as the WP No Category Base plugin, so my urls look like this: http://www.url.com/parent_category/child_category/

I only have an index.php set up at the moment, with the most basic loop possible:

<?php if (have_posts()) : ?>

<?php query_posts(); ?>
<?php while (have_posts()) : the_post(); ?>    

<div class="post">
   <?php the_title(); ?>
   <br />
   <?php the_content(); ?>

<?php endwhile; ?>    
<?php else: ?>   
<?php endif;?>  

The problem is, all posts are coming through, instead of just the posts in the category represented by the url. I didn't think I needed a custom query, because the link that took me to the particular url should have been carried across. What am I missing?

share|improve this question
up vote 2 down vote accepted

The <?php query_posts(); ?> in your code is causing the global query to be reset to show all posts instead of the one set by your rewrite rules. You should remove that line.

share|improve this answer
Oh god, embarrassing. Thanks! – danixd Feb 2 '11 at 9:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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