Multiple Loop Weirdness
-
Hi,
I’ve tried to implement multiple loops on my index.php template, by using the following code:
<?php get_header(); ?>
<div id="content" class="narrowcolumn">
<h2>Recent News</h2>
<br /><?php query_posts('category_name=News&showposts=1'); ?>
<?php while (have_posts()) : the_post(); ?>
<i>Your display code goes here</i>
<?php endwhile; ?><h2>Recent Reviews</h2>
<br /><?php query_posts('category_name=Reviews&showposts=1'); ?>
<?php while (have_posts()) : the_post(); ?>
<i>Your display code goes here</i>
<?php endwhile; ?></div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
However, when I view the page, the category names I have used seem to fool the sidebar into thinking its on an archive page for the second category (Reviews). If I remove the second loop, it fools the sidebar into thinking its on an archive page for the first category (News).
I don’t understand what I’ve done wrong here as I’ve followed the information found on https://infovore.org/archives/2005/04/12/multiple-loops/ to the letter. What am I missing out?
Also, could someone tell me what it means by ‘display code’ in that example of multiple loops? No matter what I add gives me parse errors… apologies but I’ve been learning PHP and WP stuff for only a few days and I’ve a lot to catch up on.
- The topic ‘Multiple Loop Weirdness’ is closed to new replies.