Skip to main content

Adding templates

Templates management

The table of templates is an ultimate overview over all templates created in the builder. We can take some actions:

Builderius templates table overview

  1. Add new template.
  2. Edit template.
  3. Duplicate template.
  4. Delete template.
  5. Edit template properties (the data visible in Type and Properties columns).
  6. Edit apply rules - rules which determine on which posts, pages, categories etc., the template will be used.

And we can get some info/stats:

Builderius templates table overview

  1. Title.
  2. Type - hook or regular.
  3. Properties - different template types have different properties.
  4. 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).

Builderius templates - create a new template

This will open a modal window with a two-step form wizard:

Builderius templates - create a new template

  1. Add a name
  2. Choose a desired type of the new template

Builderius has two types of templates: regular and 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:

Builderius templates - create a new template

  1. Hook name.
  2. Hook type - action or filter.
  3. Number of accepted arguments.
  4. "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:

Builderius templates - create a new template

  1. Template hierarchy group
  2. 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.

Apply rules example

  1. Remove all conditions (rules) in a specific category.
  2. Change condition (rule) operator. It can be done separately on different levels.
  3. Delete a part or the full condition (rule).
  4. Duplicate a part of the full condition (rule).
  5. Add a new condition (rule).
  6. Add a new group of conditions (rules).

Below are examples of apply rules defined for different pages.

Apply to page by ID

Apply rules example

Apply to two pages by ID

Apply rules example

Apply to two pages by ID - an alternative version

Apply rules example

Apply to two pages by ID and to posts in specific category or with a specific tag

Apply rules example

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.

note

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:

Apply rules - no post type

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:

Apply rules - enabling archive for custom post type in ACF

Editing template properties

Properties for regular template

Apply rules example

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.

Properties for hook template

Apply rules example

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.

Tutorials

Build a site with hook templates and ACF flexible content field - Builderius How to series

No Code way to extend your theme using render_block (for block themes) and hooks for Classic Themes