📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials WordPress Development The Loop

The Loop

6 min read Quiz at the end
The Loop iterates over posts — use WP_Query for custom queries; always call wp_reset_postdata().

The WordPress Loop

', '');
        the_excerpt();
        the_content();
        the_post_thumbnail('medium');
    endwhile;
    the_posts_pagination();
else :
    echo '

No posts found.

'; endif; // Custom WP_Query $args = [ 'post_type' => 'post', 'posts_per_page' => 10, 'category_name' => 'news', 'meta_query' => [[ 'key' => '_featured', 'value' => '1', 'compare' => '=' ]], ]; $query = new WP_Query($args); if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); the_title(); endwhile; wp_reset_postdata(); // ALWAYS reset! endif;
Topic Quiz · 1 questions

Test your understanding before moving on

1. What function advances the Loop to the next post and sets up global post data?
💡 the_post() advances the Loop pointer and calls setup_postdata() to make template tags work.