Title: wp_query question about if..while
Last modified: August 19, 2016

---

# wp_query question about if..while

 *  [fionagilbert](https://wordpress.org/support/users/fionagilbert/)
 * (@fionagilbert)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/wp_query-question-about-ifwhile/)
 * Hi all,
 * I have been playing around with wp_query this weekend but am not sure how to 
   rewrite this into the wp_query:
 *     ```
       <?php query_posts($query_string.'&showposts=1'); ?>
       <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
       some stuff here
       <?php endwhile; endif; ?>
       ```
   
 * I thought this would work:
 *     ```
       <?php
       $featurePosts = new WP_Query();
       $featurePosts->query('showposts=1');
       ?>
   
       <?php if ($featurePosts->have_posts()) : while ($featurePosts->have_posts()) : $featurePosts->the_post(); ?>
       Stuff here
       <?php endwhile; endif; ?>
       ```
   
 * Is this right as it does not let me display `<?php comments_popup_link('0 Comments','
   1 Comment', '% Comments'); ?>` within the ‘other stuff’
 * Thanks for any assistance.

Viewing 1 replies (of 1 total)

 *  [Jeff Cole](https://wordpress.org/support/users/upekshapriya/)
 * (@upekshapriya)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/wp_query-question-about-ifwhile/#post-794410)
 *     ```
       <?php
       $featurePosts = new WP_Query('showposts=1');
       ?>
       ```
   
 * ought to do what you want.

Viewing 1 replies (of 1 total)

The topic ‘wp_query question about if..while’ is closed to new replies.

## Tags

 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Jeff Cole](https://wordpress.org/support/users/upekshapriya/)
 * Last activity: [17 years, 10 months ago](https://wordpress.org/support/topic/wp_query-question-about-ifwhile/#post-794410)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
