Title: Multiple loop issues, two variations, neither work.
Last modified: August 18, 2016

---

# Multiple loop issues, two variations, neither work.

 *  Resolved [vagari](https://wordpress.org/support/users/vagari/)
 * (@vagari)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/multiple-loop-issues-two-variations-neither-work/)
 * I have a multiple loop on the front page that works fine for spitting out a few“
   recent posts.” But I need to same thing in a “sidebar” on some internal pages.
   The original code does not work because of whatever bug is breaking the multiple
   loops. is_page() stops working correctly.
 * [http://codex.wordpress.org/The_Loop#Multiple_Loops_Example_2](http://codex.wordpress.org/The_Loop#Multiple_Loops_Example_2)
 * Here’s that code.
 *     ```
       $temp_query = clone $wp_query;
       query_posts('showposts=5'); ?>
       <h3 class="">Recent Posts</h3>
       <ul id="rec_post_list">
       <?php while (have_posts()) : the_post(); ?>
       	<li><h4><a href='<?php the_permalink() ?>'><?php the_title(); ?></a></h4>
       	<p><?php the_time('F jS, Y') ?> · <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p></li>
       <?php endwhile; ?>
       </ul>
       <?php $wp_query = clone $temp_query; // And back to normal...
       ```
   
 * Since it used to work I really wish it wasn’t broken. Nice and simple. But I 
   figured I’d comment it out and try another version. This one worked, for the 
   most part, no breaking of “is_page” and stuff like that. But NOW I can’t get 
   comments_popup_link to work.
 *     ```
       <?php $my_query = new WP_Query('showposts=5'); ?>
       <h3 class="">Recent Posts</h3>
       <ul id="rec_post_list">
       <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
       	<li><h4><a href='<?php the_permalink() ?>'><?php the_title(); ?></a></h4>
       	<p><?php the_time('F jS, Y') ?> · <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p></li>
       <?php endwhile; ?>
       </ul>
       ```
   
 * It’s basically the same code with just the different method for grabbing the 
   query. Does anyone know why the comments_popup_link() doesn’t work anymore? the_title()
   and the_permalink() work fine. And I really need to get this fixed. I’m almost
   done with the site and I’m running out of unrelated things to do.
 * Thanks everyone!

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

 *  Thread Starter [vagari](https://wordpress.org/support/users/vagari/)
 * (@vagari)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/multiple-loop-issues-two-variations-neither-work/#post-551350)
 * OK, so since I’m trying to get this to work on an individual page according to
   the documentation it won’t work, “even when within The Loop.”
 * [http://codex.wordpress.org/Template_Tags/comments_popup_link](http://codex.wordpress.org/Template_Tags/comments_popup_link)
 * Makes sense if this is THE loop for the page. But this is an alternate “loop.”
   Anyone have any idea how to get around this? Or an alternative for multiple loops
   that would provide me with what I need and still allow this stuff?
 * Here’s the basics of the layout… I’ll try my best in unformatted text.
 * **Recent Posts**
 * Title of article one.
    April 12th, 2007 · No Comments
 * Title of Article two.
    April 5th, 2007 · 3 Comments
 * Title of Article three.
    April 1st, 2007 · 1 Comment
 * It’s nothing fancy. Thanks again everyone.
 *  Thread Starter [vagari](https://wordpress.org/support/users/vagari/)
 * (@vagari)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/multiple-loop-issues-two-variations-neither-work/#post-551351)
 * I’d be interested in other solutions to this problem. But a workaround I’ve found
   is to use comments_number() (which isn’t exactly the same statistic) and manually
   create the URL.
 * `<a href="<?php comments_link(); ?> "><?php comments_number('No responses','One
   response','% responses'); ?></a>`

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

The topic ‘Multiple loop issues, two variations, neither work.’ is closed to new
replies.

## Tags

 * [Comments](https://wordpress.org/support/topic-tag/comments/)
 * [loops](https://wordpress.org/support/topic-tag/loops/)
 * [multiple](https://wordpress.org/support/topic-tag/multiple/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 1 participant
 * Last reply from: [vagari](https://wordpress.org/support/users/vagari/)
 * Last activity: [19 years, 1 month ago](https://wordpress.org/support/topic/multiple-loop-issues-two-variations-neither-work/#post-551351)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
