With the Loop and the template hierarchy both covered, these four files are just a matter of combining them. Each one exists because the hierarchy checks for it by name — none of this is magic, just the pattern from the last two lessons applied a few times over.
<?php get_header(); ?>
<main>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<article>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
</article>
<?php endwhile; ?>
<?php else : ?>
<p>Nothing found.</p>
<?php endif; ?>
</main>
<?php get_footer(); ?>Because index.php is the fallback for lists of posts (the blog listing, category archives, search results, and more), it loops over multiple posts and shows an excerpt and a link — not the full content, which belongs on the single post itself.
Both follow the same shape: one item, full content, no excerpt. The only real difference between them in practice is often the surrounding markup:
<?php get_header(); ?>
<main>
<?php while ( have_posts() ) : the_post(); ?>
<article>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
</article>
<?php endwhile; ?>
</main>
<?php get_footer(); ?>A single post commonly adds the publish date, author, or category alongside the title; a page usually doesn't need any of that. Beyond that, the files are close to identical, which is exactly why the hierarchy treats them as two separate template slots in the first place.
A 404 page has nothing to loop over — there's no post that matched — so it skips the Loop entirely and just shows a message and something useful to do next:
<?php get_header(); ?>
<main>
<h1>Page Not Found</h1>
<p>Sorry, nothing matched that address.</p>
<?php get_search_form(); ?>
</main>
<?php get_footer(); ?>get_search_form() outputs WordPress's built-in search box — genuinely useful on a 404 page, since a visitor who hit a broken link often knows roughly what they were looking for.
This is a starting point
All four of these files can — and usually should — grow well beyond this minimal shape: pagination on index.php, comments on single.php, a featured image at the top of page.php. What's here is the skeleton every real version starts from, not the ceiling.
With the core templates in place, the next lesson looks at a different kind of page template — one you assign by hand to a specific page, rather than one WordPress picks automatically.