Meaning
Template Files are PHP files within themes that determine page structure, content layout, and element display for different content types and views.
Definition
WordPress uses a template hierarchy system to select which file renders each page. Common template files include: index.php (default fallback), single.php (individual posts), page.php (individual pages), archive.php (post listings), category.php (category archives), search.php (search results), and 404.php (not found pages).
Template files contain a mixture of HTML structure, PHP logic, and WordPress template tags (functions like the_title(), the_content(), and get_sidebar()). Themes can include increasingly specific templates: single-{post-type}.php for custom post types, page-{slug}.php for specific pages, or category-{slug}.php for particular categories.
Understanding template hierarchy is crucial for theme development and customization. WordPress checks for the most specific template first, falling back through the hierarchy until reaching index.php as the ultimate fallback.
Example
When a visitor views a single blog post, WordPress checks for templates in order: single-{post-slug}.php → single-post.php → single.php → singular.php → index.php. If the theme includes single.php, WordPress uses that file to render the post. Developers customize single.php to control exactly how blog posts appear: sidebar layout, author bio, related posts, and comments section.

