Support » Plugins » WP_query issue

  • Resolved Dunkkan


    Hello, I’m just starting to learn PHP and I figured out how to retrieve 9 random posts in single.php, before the main loop :

    <?php $my_query = new WP_Query('showposts=9&orderby=rand'); ?>
    	<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
    	<?php the_title(); ?>
    	<?php the_excerpt(); ?>
    	<?php endwhile; ?>

    I’m getting beautifully several random posts, but not always the 9 posts I specified. Sometimes is giving me just 4 or 5 posts.

    Do you know how to fix that behaviour ?


Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘WP_query issue’ is closed to new replies.