• Resolved MrKid

    (@mrkid)


    Hi,
    i have some problem with the multiple loop!

    My theme has 3 columns; in my left column there is this code for 5 categories:

    <?php require('wp-blog-header.php'); ?>
    <?php query_posts('showposts=1&cat=39'); global $more; $more = 1; while (have_posts()) : the_post(); ?>
    
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permalink a <?php the_title(); ?>"><?php the_title(); ?></a>
    
    <?php the_content_rss('', false, '', 20); ?>
    <?php endwhile; ?>

    in the central column there is this code:

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    
    <?php the_time('l, j M, Y') ?><?php comments_popup_link('0', '1', '%'); ?>
    
    <h2><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title() ?></a></h2>
    <h5>Categories: <?php the_category(', '); ?></h5>
    <?php the_excerpt(''); ?>

    The problem is in the second column, because it doesn’t visualize the articles, but only the same article of the first column.

    Could you help me with this code???
    Thanks a lot

Viewing 3 replies - 1 through 3 (of 3 total)
  • Your problem is that when you call your second loop in your central column, the first query posts from your left column is still active… This query_posts still ask worpress to show one post from category 39.

    the solution is to add this line :

    <?php wp_reset_query(); ?>

    Right after your <?php endwhile; ?> in the left column…

    It should do the trick

    S.

    Thread Starter MrKid

    (@mrkid)

    Ohhhhhhhhhhhhhhhhh
    Thanks a lot guys !!!!
    SimonJ i have used your solution and with the “wp_reset_query” is all ok!
    thanks thanks thank

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Multiple loop… big problem’ is closed to new replies.