OK… here is a problem that I never solved.
If I have a “classic loop”, just like in single.php for instance, folowing a loop based on query_posts, the query seems to saty active for the second loop…
Let’s say I want to use this code in my header :
<?php query_posts('cat=12&showposts=1'); ?> <?php while (have_posts()) : the_post(); ?> --- My stuff --- <?php endwhile; ?>
And, this loop in my single.php :
<?php while (have_posts()) : the_post(); ?> --- My stuff --- <?php endwhile; ?>
Since I called the query_posts in the header before the loop to display the content of the single posts, the query_posts, and the arguments it contains, stays active…
So I end up with a single posts whom display, in this code example, one post from category 12…
Another example, if I want to use tables to display some stuff (and please, don’t tell me I shouldn’t use table…:-))
If I call the query_posts in the first column (td), then the “classic loop” for the single posts in the second column, the query_posts stay active.
I understand why… the second
<?php while (have_posts()) : the_post(); ?>is just another call to this same query, so WordPress display the stuff based on the same result…
So is there a way to stop the query_posts ?
- The topic ‘How to stop query_posts ?’ is closed to new replies.