Understanding WordPress Template Hierarchy
WordPress follows a specific order when selecting template files. The theme provides templates at different levels of specificity, allowing WordPress to fall back to more generic templates when specific ones don’t exist.WordPress always checks for the most specific template first, then falls back to more generic options.
Available Template Files
Zalbi Theme includes the following template files:Front Page
Single Post/Page Templates
Archive Templates
Search & Error Templates
Core Templates
Partial Templates
Template Hierarchy Flow
1. Front Page Display
When visitors access the homepage:front-page.php provides a custom homepage layout for Zalbi.
2. Single Inflatable (Hinchable)
When viewing a single inflatable at/catalogo/inflatable-name/:
single-hinchable.php Implementation Details
single-hinchable.php Implementation Details
Features:
- Bilingual content (Spanish/Euskera)
- ACF field integration:
medidas(measurements)capacidad(capacity)etiqueta_color(color tag)
- Custom breadcrumb navigation
- Category-based color coding
- Translated category names
single-hinchable.php:1Language Detection:3. Single Event (Evento)
When viewing a single event at/eventos/event-name/:
single-evento.php provides event-specific layout and functionality.
4. Catalog Page
When viewing the catalog page:page-catalogo.php Implementation Details
page-catalogo.php Implementation Details
Template Name: “Plantilla Catalogo”Features:
- Category filtering system
- Custom taxonomy query (
tipo_hinchable) - Bilingual category display
- Custom ordering of inflatable types:
- Hinchables/Puzgarriak (Inflatables)
- Acuáticos/Uretakoak (Aquatics)
- Deportivos/Kirol atrakzioak (Sports)
- Juegos/Jokoak (Games)
page-catalogo.php:1Category Order Configuration:5. Events Page
When viewing the events archive:page-eventos.php displays event listings.
6. Blog Posts
When viewing a single blog post:single.php provides the default single post layout.
7. Pages
When viewing a standard page:page.php handles all standard pages.
8. Archives
When viewing category, tag, or date archives:archive.php handles all archive pages.
9. Search Results
When displaying search results:search.php formats search results.
10. 404 Error
When a page is not found:404.php provides user-friendly error messaging.
Template Parts
Reusable template components intemplate-parts/ directory:
Content Templates
content.php
Default post content loop templateUsed in: archive.php, search.php, index.php
content-page.php
Page content layoutUsed in: page.php
content-search.php
Search result item formattingUsed in: search.php
content-none.php
No results found messageUsed in: archive.php, search.php
Loading Template Parts
Template parts are loaded using WordPress functions:Custom Template Assignment
Assigning Page Templates
Page templates can be assigned in the WordPress admin:- Edit a page in WordPress admin
- Look for “Page Attributes” or “Template” in the sidebar
- Select from:
- Default Template (uses
page.php) - Plantilla Catalogo (uses
page-catalogo.php)
- Default Template (uses
page-eventos.php is automatically used when the page slug matches, not through template selection.Template Loading Order Summary
Visual Hierarchy Chart
Visual Hierarchy Chart
Best Practices
Specificity
Create specific templates only when needed. Zalbi Theme provides specific templates for custom post types while using generic templates for standard content.
DRY Principle
Use template parts to avoid code duplication. The
template-parts/ directory contains reusable components.Fallback Safety
Always maintain
index.php as the ultimate fallback. This ensures the theme never fails to load.Consistent Structure
Follow WordPress coding standards and maintain consistent file naming conventions.
Related Resources
Theme Overview
Return to the architecture overview
File Organization
Detailed breakdown of every file