Support » Themes and Templates » Help with Multiple Loops in Index Page

  • Greetings All,

    I’m a newbie trying to code a custom structure for my index.php page [ for the default home page ] in wordpress. So far, I’ve tried various approaches but don’t seem to be making any progress [ my page just shows up as blank when tested ].

    In a nutshell, I’m trying to achieve the following structure

    – Header = (Logo, Search Form) + (Navigation)
    – Leader Board = (Text Widget + Posts Slideshow {smoothgallery})
    – Content = Row 1 ( Category Title + Brief Description (Hard Coded in HTML) + 4 Most Recent Posts { Post Title Permalink, Post Thumbnail, Post Excerpt } ) + ( Category Title + Brief Description (Hard Coded in HTML) + 4 Most Recent Posts { Post Title Permalink, Post Thumbnail, Post Excerpt } ) + ( Category Title + Brief Description (Hard Coded in HTML) + 4 Most Recent Posts { Post Title Permalink, Post Thumbnail, Post Excerpt } )
    – Footer

    With the above layout, it is evident that I have to use multiple loops for the Category-Posts lists.

    Could someone please help out with the multiple loops [ where possible, a working code would be super 😛 ] for the content section, I’m desperate.

    Cheers

Viewing 3 replies - 1 through 3 (of 3 total)
  • While there may be multiple ways to do this, I have always resorted to creating my own custom loop for things that aren’t part of the “main blog.” I use this article on weblogtoolscollection to guide me each time. Here is there example code:

    <h3>Recent Articles</h3>
    <ul>
    <?php
        $recentPosts = new WP_Query();
        $recentPosts->query('showposts=5');
    ?>
    <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
        <li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    </ul>

    @taylorde,

    Thanks for the loop code…quick question: Can I use the same loop multiple times on the same page? In my earlier question, I want to use the loop 3 times [ for the three different category column blocks in the same content area ]

    Cheers

    Yeah, you can create as many as you want. I typically rename the $recentPosts variable to something that is topical.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Help with Multiple Loops in Index Page’ is closed to new replies.