WordPress.org

Ready to get started?Download WordPress

Forums

Multiple Loop (1 post)

  1. patung
    Member
    Posted 7 years ago #

    Could somebody tell me how to reverse the order of this bit of code from the codex.

    <?php $my_query = new WP_Query('category_name=featured&showposts=10'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; ?> <!-- Do stuff... --> <?php endwhile; ?>

    and then

    <?php if (have_posts()) : while (have_posts()) : the_post();
    if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
    <!-- Do stuff... -->
    <?php endwhile; endif; ?>

    So that the first call to the loop displays all posts EXCEPT posts from category_name=featured
    and the second call to the loop displays ONLY posts from category_name=featured, that is, basically reversing the order that is given in the codex.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags