A template does nothing until you say where it applies. That is a display condition: include this template on these pages, exclude it from those.
“Use this single template for products, but not for the sample product.”
Where you can point a condition
| Group | Conditions |
|---|---|
| General | Entire Site, Front Page, Blog Home, Search Results, 404 |
| Singular | All Singulars, By Post Type, Specific Entry, Child Of (pages), By Term, By Author |
| Archive | All Archives, Author Archive, Date Archive, Post Type Archive, Taxonomy Archive, Specific Term Archive |
Each template type accepts the groups that make sense for it. Single templates take the Singular group, archives take the Archive group, and headers and footers take all three, because chrome can apply anywhere. Loop items take By Post Type, Specific Entry, By Term and By Author.
Which template wins
One template renders each slot. When several match, the most specific wins: Entire Site loses to All Singulars, which loses to By Post Type, which loses to Specific Entry. A condition naming one thing beats a condition naming a category of things.
If two templates tie, the higher priority number wins, then the more recently edited.
“List the display conditions and tell me which template wins for this page.”
Search and 404
These two are special: they take no conditions. A Search Results template renders the search page and a 404 template renders the not-found page. Build one of each and it applies.
They still appear in the General group as conditions, which is how you give the search page its own header.
Showing and hiding chrome
Header and footer can be turned off. The controls differ, and this is worth knowing because it catches people out:
- On a template,
showHeaderandshowFooterare true or false, andchromeModesets the overall behaviour. - On an entry: a page, post, or product,
showHeaderandshowFootertakeinherit,showorhide.inheritmeans follow the template.
So a landing page that needs no navigation is one request: “Hide the header and footer on the Thanks page.”
For developers
Specificity is scored: entire_site 20, all_singular / all_archives 30, front_page / blog / search / not_found 40, post_type / post_type_archive / taxonomy 50, child_of / term / author / date_archive 60, term_archive and author_archive with an author 70, post 80. A designated default with no conditions scores 10. Ties break on priority (0 to 9999), then post_modified_gmt, then post ID.
Conditions are include or exclude; an exclude match rejects the template outright. The catalog, including which names each type accepts, is filterable via 21press_delta_condition_catalog and 21press_delta_condition_catalog_by_type.