Course Using WordPress Themes

How Themes Work: Templates & Hierarchy

Theme Basics Preview

Inside a theme

The template hierarchy

WordPress decides which template file to use based on the type of content being viewed. This order of priority is called the template hierarchy.

  • single.php — a single post
  • page.php — a single page
  • home.php — the blog index
  • archive.php — category or tag listings
  • 404.php — "not found" pages
  • functions.php — the theme's settings and features

How content gets into the template

A template is mostly HTML with PHP functions that pull content from the database. For example, the_title() prints the post title and the_content() prints the body.

Why this matters to you

You do not need to write PHP to use WordPress, but understanding the hierarchy explains why a "page" looks different from a "post", and why some themes feel more flexible than others.

Tip: The block themes of today largely hide this hierarchy — but the concepts underneath still apply.

This is a free preview lesson

Enroll in the Using WordPress Themes to unlock every lesson, lesson PDF guides, quizzes and your certificate - and start creating your own pieces today.


Discussion