Every template that shows post or page content — index.php, page.php, single.php, and more — does it through the same pattern, called the Loop. It's not a special WordPress feature so much as a naming convention for a specific, always-the-same while loop.
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<?php endwhile; ?>
<?php endif; ?>have_posts() checks whether there's another post left to show. the_post() advances to it and sets up all the "current post" data that the tags inside the loop read from. On a single page this only runs once; on an archive or the homepage, it runs once per post in the list.
These only work inside the Loop — call them outside it and there's no "current post" for them to read from:
| Tag | Outputs |
|---|---|
the_title() | The post/page title |
the_content() | The full post/page content |
the_excerpt() | A short auto-generated (or manually set) summary |
the_permalink() | The post/page's URL |
the_ID() | The post/page's numeric ID — useful for passing to other functions |
get_the_date() | The publish date, formatted (returns rather than outputs, so it's wrapped in echo) |
Conditional tags answer "what kind of page is this?" and work anywhere in a template, not just inside the Loop — they're what makes a single header.php able to behave differently across the whole site:
| Tag | True when |
|---|---|
is_front_page() | The site's configured homepage is being shown |
is_home() | The main blog listing is being shown (same as is_front_page() unless a static homepage is set) |
is_single() | A single blog post is being shown |
is_page() | A standalone page is being shown |
is_archive() | Any archive listing — category, tag, date, or custom taxonomy — is being shown |
is_home() vs. is_front_page()
is_home() and is_front_page() trip people up constantly. They're identical only when a site's homepage is the blog listing. The moment a site uses a static page as its homepage (Settings → Reading), the two split apart — is_front_page() follows that setting, is_home() always means "the blog listing," wherever it ends up living.
With posts and pages actually rendering, the next lesson steps back and looks at how WordPress decided which template file to use in the first place — the template hierarchy.