0

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(); ?>
</div>

<?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?

1 Answer 1

2

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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