The table of templates is an ultimate overview over all templates created in the builder. We can take some actions:
- Add new template.
- Edit template.
- Duplicate template.
- Delete template.
- Edit template properties (the data visible in Type and Properties columns).
- Edit apply rules - rules which determine on which posts, pages, categories etc., the template will be used.
And we can get some info/stats:
- Type -
- Properties - different template types have different properties.
- Author and creation date.
Setting up a template
Adding a new template
In order to create a new template we go to Templates page (1), then click on "Add new" button (2).
This will open a modal window with a two-step form wizard:
- Add a name
- Choose a desired type of the new template
Builderius has two types of templates:
hook. Regular template is essentially a blank canvas template that
overrides anything coming from the theme (as well as removes any styles and scripts which are coming from the theme). We
use it when we need a full page template. On the other hand, we choose Hook template when we want to display something
without overriding the original template coming from the theme. Common use cases are displaying related posts section at the
bottom of the post page, displaying site-side banner in the header etc.
To recap, let's review how these two types of templates are being displayed:
regular- completely overrides theme template; at the beginning it is a blank canvas;
hook- is getting outputted when specific hook (action or filter) is being used and does not override theme template;
In the template creation wizard, for
regular template no other fields will be shown. For
hook template type we have
additional fields to be filled in:
- Hook name.
- Hook type - action or filter.
- Number of accepted arguments.
- "Replace other hooked content" checkbox.
After defining/filling additional fields, when applicable, click on "Next step" button. The next step is dedicated to Apply rules - the conditions for displaying the template for specific pages:
- Template hierarchy group
- Starters dropdown
All apply rules are organized by groups. The first group - template hierarchy is a required to be filled in. Other groups are optional. Many groups have starters for a fast and easy selection of apply rules. More information about using apply rules builder is given in the next section.
After the "Apply rules" are defined, click on "CREATE TEMPLATE" button. The template will be created.
Defining apply rules
For a template to be visible on the site it has to be applied for certain pages. There is no division to template types like "header/footer" or "main content". Each template is a full page.
- Remove all conditions (rules) in a specific category.
- Change condition (rule) operator. It can be done separately on different levels.
- Delete a part or the full condition (rule).
- Duplicate a part of the full condition (rule).
- Add a new condition (rule).
- Add a new group of conditions (rules).
Below are examples of apply rules defined for different pages.
Apply to page by ID
Apply to two pages by ID
Apply to two pages by ID - an alternative version
Apply to two pages by ID and to posts in specific category or with a specific tag
After the Apply Rules are being set, we have to click on the
Save changes button to save changes.
In order to discard the changes made, we click on the
Cancel & close button.
It might happen it is not possible to choose a post type (the last select) while adding a rule for custom post type archive. It look like this:
This happens when param
has_archive is set to false during teh registration of custom post type. More
info about registration of custom post type via code.
Those who uses ACF 6.2+ for adding custom post types, the setting that enables custom post type archive looks like this:
Editing template properties
Since several templates might be applied to the same page (or pages), we use sort order to specify the priority of such templates; the lower value of the sort order means higher priority.
One or more templates can be added by using the same hook name, so "Hook Priority" is an important parameter that impacts the order of applying such templates.