WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Multiple loop not working - displaying standard 10 posts (2 posts)

  1. selfcomposed
    Member
    Posted 5 years ago #

    I have a 3-column layout. I am trying to achieve a setup where the entirety of the latest post displays in the left, widest column by itself. In the middle column, part of sidebar.php, the next 7 most recent post titles and excerpts, followed by 8 titles only.

    I'm using the following code to achieve these three separate loops:

    <?php query_posts('showposts=1'); ?>
    <?php $posts = get_posts('numberposts=5&offset=0'); foreach ($posts as $post) : start_wp(); ?>
    <?php static $count1 = 0; if ($count1 == "1") { break; } else { ?>
    
    <!-- SECOND LOOP: display post excerpts 2 thru 8 -->
    <?php query_posts('showposts=7'); ?>
    <?php $posts = get_posts('numberposts=5&offset=1'); foreach ($posts as $post) : start_wp(); ?>
    <?php static $count2 = 0; if ($count2 == "7") { break; } else { ?>
    
    <!-- // THIRD LOOP: display post titles 8 thru 15 -->
    <?php query_posts('showposts=8'); ?>
    <?php $posts = get_posts('numberposts=5&offset=8'); foreach ($posts as $post) : start_wp(); ?>
    <?php static $count3 = 0; if ($count3 == "8") { break; } else { ?>

    The first loop is located in my index.php file, while the 2nd and 3rd are located in the sidebar.php.

    What is broken? Why is the standard 10 entries displaying in the middle column instead

  2. selfcomposed
    Member
    Posted 5 years ago #

    Bleh. Attention to detail. One of the quickest ways I can see the mistake I made on my own is to ask the world to look for it.

    I neglected to change the numberposts= in the third line of each loop.

Topic Closed

This topic has been closed to new replies.

About this Topic