Forums

[resolved] multiple loops rewind_posts question (3 posts)

  1. nielz
    Member
    Posted 11 months ago #

    Hi there,

    I am working on a site where I want to use multiple loops to request (Flutter) data.
    I use the folowing code several times to load data in multiple columns:

    <?php
    query_posts('category_name=item1');
    if(have_posts()) : while(have_posts()) : the_post();
    echo get('column1');
    endwhile;
    endif;
    ?>

    This code works fine now but I read that you maybe should use <?php rewind_posts(); ?> before each new loop on the same page.
    Does anybody now if this is necessary and why?

    Regards,

    Niels

  2. alchymyth
    The Sweeper
    Posted 11 months ago #

    you would use 'rewind_posts()' if you want to re-use the same query for the second loop;
    it is neither needed nor useful if you use a new query for the second loop.

    for other than the main loop, it is advisable to use WP_Query() or get_posts().

    in case you haven't read this yet, general info:
    http://codex.wordpress.org/The_Loop

  3. nielz
    Member
    Posted 11 months ago #

    Thanks!

Reply

You must log in to post.

About this Topic