Templates

Template files are also a part of your theme and play an important role in how the website is displayed to the site visitors. It mainly deals with the website layout and its components. Some examples of the template files are header.phpcomments.php, and index.php.

By the way, the template files in WordPress are reusable. This means that you can use query strings to call a template or a set of templates dynamically. These query strings look for template files with specific names in the current theme’s directory and use the first matching template file as specified by the hierarchy.

Explore these videos for insights and tutorials on Template Files and Template Parts. This section comprises 7 modules with a combined duration of 1 hour 25 minutes.

Video ContentTime
Basic Overview18:53
Template Files10:49
Template Parts05:09
Template Hierarchy06:26
Conditional Tags, Template Tags & Custom Page Templates12:17
Internal Working Pt. 124:59
Internal Working Pt. 207:33

Go through the following handbook pages to learn all about templates and template parts.

Ideas to Explore:

  • What is the difference between singular.php and single.php templates? Which one is more specific?
  • What are the differences between templates of the block theme and the classic theme?
  • How can you use template hierarchy to create a custom template for a custom post type in your theme?
  • How do you implement a conditional template that applies to specific categories or tags?