How to loop with both newest and recent commented posts. (3 posts)

  1. enderpal444
    Posted 3 years ago #

    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?

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    In theory, yes. Start with multiple Loops.

  3. enderpal444
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.