[resolved] Loop posts only show with Recent Posts widget (2 posts)

  1. peanutterbutter
    Posted 3 years ago #

    Pretty sure I'm missing something obvious, but I have a basic loop that calls the last post, then pulls the title, thumbnail, and content. It works fine with the default Recent Posts widget in the sidebar, but when I remove it, the content is empty (but thumb and title still show up fine).

    <div id="latest-post">
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : query_posts('p=1'); ?>
    <h1><?php  the_title(); ?></h1>
    <?php echo get_the_post_thumbnail(); ?>
    <?php the_content('Read on ยป') ?>
    <?php endwhile; ?>
    <?php endif; ?>
    </div><!-- #latest-post -->

    It's not a huge deal, I can live with the recent posts widgets, but I'm just wondering what I'm missing, and I couldn't find anything on it.

  2. peanutterbutter
    Posted 3 years ago #

    Solved, added a reset before starting my loop.

    <?php wp_reset_postdata(); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic