WordPress.org

Ready to get started?Download WordPress

Forums

Multiple Loop (6 posts)

  1. akira01
    Member
    Posted 6 years ago #

    I tried to create a multiple loop with different set of css but no matter what I tried, it doesn't work. Here's my code :
    
    <strong>Loop1</strong>
    <?php query_posts($query_string . '$showposts=4'); ?>
    <?php while (have_posts()) : the_post(); ?>

    <div class="article">
    " rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php post_image('attachment'); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?>

    <p class="date"><?php the_time('D, M j') ?> <!-- by <?php the_author() ?> --></p>
    <p><?php the_excerpt('Read the rest of this entry »'); ?></p>
    <p>Comments <?php comments_popup_link('(0)', '(1)', '(%)'); ?> · " rel="bookmark" title="Permanent Link to <?php the_title(); ?>">Read More</p>
    </div>

    <?php endwhile; ?>
    </div></div>`

    Loop 2

    <div class="mainarticles-sub"><div class="clearfix">
    <?php query_posts($query_string . 'showposts=4&&offset=4'); ?>
    <?php while (have_posts()) : the_post(); ?>
    
    <div class="article">
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php post_image('attachment'); ?></a><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
    
    <p class="date"><strong><?php the_time('D, M j') ?> <!-- by <?php the_author() ?> --></strong></p>
    	<p><?php the_excerpt('Read the rest of this entry &raquo;'); ?></p>
    <p><strong>Comments <?php comments_popup_link('(0)', '(1)', '(%)'); ?> &middot; </strong><a class="continue" href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">Read More</a></p>
    </div>
    
    		<?php endwhile; ?>
    </div></div>

    The posts keeps repeating.

    Please advise.
    Thanks in advance

  2. alakhnor
    Member
    Posted 6 years ago #

    For what you've shown, there's no need to have multiple loops.
    Just add <?php $i=1; ?> before while (have_posts())
    And then, inside the loop:

    <?php if ($i < 5) : ?>
    // code for 4 first posts
    <?php else : ?>
    // code for 4 next posts
    <?php endif;

    and then, <?php $i++; ?> before endwhile;

  3. akira01
    Member
    Posted 6 years ago #

    Hi,
    Thanks for the tips but it doesn't help. Let me explain what I intend to have :

    I want the first row of posts to appear this way
    <div class="mainarticles-sub"><div class="clearfix">
    <div class="article">
    POST ONE
    </div>

    <div class="article">
    POST TWO
    </div>

    <div class="article">
    POST THREE
    </div>
    </div></div>

    Then the second row
    <div class="mainarticles-sub"><div class="clearfix">
    <div class="article">
    POST FOUR
    </div>

    <div class="article">
    POST FIVE
    </div>

    <div class="article">
    POST SIX
    </div>
    </div></div>

    Please advise. Your help on the above is very very much appreciated.

    Thanks in advance

  4. akira01
    Member
    Posted 6 years ago #

    Any help would be very much appreciated. I tried all kinds of loop and it just doesn't work the way I want (as stated in my 2nd post)

    Please advise. Thanks

  5. akira01
    Member
    Posted 6 years ago #

    Anyone please, I really need to solve this before my site go live. Now I'm stuck only this part.

    Thanks a million in advance.

  6. akira01
    Member
    Posted 6 years ago #

    Can anyone offer your valuable help? I believe wordpress can do this but i just couldn't figure out how.

    Please advise.
    Thanks in advance.

Topic Closed

This topic has been closed to new replies.

About this Topic