PHP code view · how each template file is structured
How theme files are assembled when a visitor loads a static page · page.php
When WordPress serves a page it starts with index.php, which calls wp_head() — pulling in header.php. The matching template (page.php) retrieves content from the database. footer.php closes the document. functions.php underpins the whole site.
category.php — The Loop outputs multiple posts using the_excerpt()
A category page lists multiple posts. WordPress checks the template hierarchy and uses category.php if present. The Loop runs once per post, outputting a title, date and excerpt for each. Note the_excerpt() — not the full content.
Runs once per post in this category. Each iteration outputs one <article>.
single.php — full content, meta, taxonomy, navigation, comments
A single post uses single.php. Like page.php it calls the_content() — but it also includes date/author meta, taxonomy terms, previous/next navigation, and comments_template(). The Loop runs but iterates only once.
the_title() — titlethe_date() — datethe_author() — authorthe_content() — full bodythe_excerpt() in category.phpthe_category() — categoriesthe_tags() — tagsprevious_post_link()next_post_link()comments_template() loads comments.php — form + list| HTML prototype | WordPress theme |
|---|---|
| <h1>Post Title</h1> | <?php the_title(); ?> |
| <p>13 Apr 2020</p> | <?php the_date(); ?> |
| <p>by Prisca</p> | <?php the_author(); ?> |
| <!-- body text --> | <?php the_content(); ?> |
| <p class='cats'>…</p> | <?php the_category(); ?> |
| <p class='tags'>…</p> | <?php the_tags(); ?> |
| <!-- prev/next --> | <?php previous/next_post_link(); ?> |
| <!-- comment form --> | <?php comments_template(); ?> |
404.php — displayed whenever WordPress cannot find a matching post or page
When a URL returns no content, WordPress loads 404.php. There is no Loop — there is no post to retrieve. Instead the template displays a static message and typically includes a search form so the visitor can try again. The form uses WordPress's built-in get_search_form() or a hand-coded <form> with action='/' and input[name=s].
error404get_search_form() loads searchform.php if it exists, otherwise outputs the default WP formname="s" — WP's search query parameterthe_search_query() pre-fills the fieldthe_widget() can add recent posts, categories, or tag cloud to help the visitorsearch.php — displays results for a visitor's query using the Loop
When a visitor submits a search (via the ?s= query parameter), WordPress loads search.php. Like category.php it uses the Loop to output multiple matching posts, each with title, date and excerpt. It also handles the empty-results case when no posts match.
Runs once per matching post. If no posts match, the else branch shows a message and a fresh search form.