• link

    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(); ?>

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Loop returning 1 or 2 post results when asking for 3’ is closed to new replies.