treehouse : what would you like to learn today?
Web Design Web Development iOS Development

WordPress Loop is looping stuff I don't want to be Looped =)

  • He there...

    I got a WP loop that has to put out a list of news items.

    The 1th column is the latest post in the category news, the second column shows the second, third and fourth post in the same category "news" and the third and last column is listing the fifth+ titles from also the same category.

    The problem is that I can't seem to figure out why and how the loop is putting the ie. col_three in the loop. I'm guessing I need to stop the loop somehow, open the div class col_three, and start the loop again.

    Hope I make some sense...

    This is what I got:


    <section>

    <div id="news">

    <?php $list_news = new WP_Query('cat=3&showposts=-1'); ?>
    <?php $count = 0; ?>
    <?php while ($list_news->have_posts()) : $list_news->the_post(); $do_not_duplicate = $post->ID; ?>
    <?php $count++; ?>
    <?php if ($count == 1) : ?>

    <div class="col_one">

    <article>

    <h3><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h3>

    <?php the_content(); ?>

    </article>

    </div> <!-- col_one -->

    <?php elseif ($count == 2 || $count == 3 || $count == 4) : ?>

    <div class="col_two">

    <article>

    <h3><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h3>

    <?php the_content(); ?>

    </article>

    </div> <!-- col_two -->

    <?php else : ?>

    <div class="col_three">

    <article>

    <h3><a href="<?php the_permalink(); ?>" ><?php the_title(); ?></a></h3>

    </article>

    </div> <!-- col_three -->

    <?php endif; ?>
    <?php endwhile; ?>

    </div> <!-- end news -->

    </section>


    Above and below this section I query posts from a different category.



    <section>

    <article id="">

    <?php query_posts('cat=1&posts_per_page=5');

    if (have_posts()) : while (have_posts()) : the_post();

    the_title ();
    the_content();

    endwhile; endif; ?>

    </article>

    </section>



    Thanks in advance!
    Paul