Loop returning 1 or 2 post results when asking for 3
-
The following loop sometimes gives me 3 results, sometimes 2 and sometimes 1. Anyone understand why this would happen? And how to fix?
Yes – there are thumbnails for every post.` <?php
wp_reset_query();
global $post;
$query = new WP_Query(“showposts=3&post_type=’story’&orderby=rand”);
?>
<?php if ( $query->have_posts() ) : ?>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<?php $size = ‘thumbnail’; ?>
<?php echo “” . get_the_post_thumbnail( $post_id, $size) .’‘; ?>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
- The topic ‘Loop returning 1 or 2 post results when asking for 3’ is closed to new replies.