Support » Fixing WordPress » “showposts” not working in WP_Query

  • I upgraded my WordPress blog from 2.5.1 to 2.6 and noticed that this piece of code will work:

    <?php $my_query = new WP_Query('category_name=home&showposts=-1'); ?>
    
    <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
      <?php echo ", $post->post_name"; ?>
    <?php endwhile; ?>

    And this one won’t:

    <?php $my_query = new WP_Query('category_name=home&showposts=3'); ?>
    
    <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
      <?php echo ", $post->post_name"; ?>
    <?php endwhile; ?>

    The difference between these is in the query. When I put -1 for showposts, it works. If I put any other number (ie. 3), the output disappears completely.

    What happened?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘“showposts” not working in WP_Query’ is closed to new replies.