Support » Fixing WordPress » How to loop with both newest and recent commented posts.

  • Im trying to setup a look that works like a forum loop in that it shows at the top both the newest posts mixed with the most recent commented posts. So when a new post in that category is made it appears at top but when another post gets commented on it jumps ahead of it. Possible?

Viewing 2 replies - 1 through 2 (of 2 total)
  • esmi

    (@esmi)

    Forum Moderator

    In theory, yes. Start with multiple Loops.

    Unless I missed the answer I think that only allows to display multiple loops one after the other like this.

    <?php $my_query = new WP_Query('category_name=featured&posts_per_page=1');
      while ($my_query->have_posts()) : $my_query->the_post();
      $do_not_duplicate = $post->ID;?>
        <!-- Do stuff... -->
      <?php endwhile; ?>
        <!-- Do other stuff... -->
      <?php if (have_posts()) : while (have_posts()) : the_post();
      if( $post->ID == $do_not_duplicate ) continue; ?>
       <!-- Do stuff... -->
      <?php endwhile; endif; ?>

    How do the forums do it? I want a loop that mixes both latest commented on and recently posted so that if the fist post is either the newest post or the most recently commented depending on which was done before the other.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to loop with both newest and recent commented posts.’ is closed to new replies.