query_posts() is messing up the main loop
-
I have posts which labeled category_name=news. I want to list all these post on the left sidebar by doing …
<ul> <?php query_posts('category_name=news'); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <li> <a href="<?php the_permalink() ?>"><?php the_title() ?> »</a><br /> <small><?php the_time('F jS, Y') ?></small> </li> <?php endwhile; endif; ?> </ul>
However, as soon as I do this, it breaks the post listing of my whole site. It is almost as if the above query_posts function is interferring with the main loop in index.php.
As soon as I remove query_posts in the above, then my site works.
How I can just get a list of posts that are categorized as “news” and list them on the left sidebar?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘query_posts() is messing up the main loop’ is closed to new replies.