WordPress.org

Forums

wp_query question about if..while (2 posts)

  1. FionaGilbert
    Member
    Posted 7 years ago #

    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.

  2. Jeff
    Member
    Posted 7 years ago #

    <?php
    $featurePosts = new WP_Query('showposts=1');
    ?>

    ought to do what you want.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags