Template parts
Template Parts let you design the header, footer and other site-wide blocks in Elementor, then choose where each one appears with rules such as “Entire Website”, “All Posts” or “Only the Contact page”.
Needs: Elementor and Advanced Custom Fields Pro. The rule fields use ACF repeaters, which are part of ACF Pro.
Template types
| Type | Value | Shown |
|---|---|---|
| Header | header | Where its display rules match |
| Footer | footer | Where its display rules match |
| Above Footer | above_footer | Where its display rules match, typically a call-to-action above the footer |
| 404 Page | 404 | On 404 pages. No rules needed. |
| Submenu | submenu | Wherever the theme or a shortcode places it, for example inside a mega menu |
| Custom | custom | Wherever the theme or a shortcode places it |
Creating a template part
- In the admin, open your theme’s menu and choose Template Parts. You can also use + New → Template Part in the admin bar.
- Click Add New and enter a title.
- Under Template Settings, choose a Template Type.
- For headers, footers and above-footer blocks, add Display Rules and, if needed, Exclude Rules.
- Optionally add a Note. It appears only in the admin list.
- Publish, then click Edit with Elementor to design the template.
The editor opens on a blank Elementor Canvas page. Template parts can’t be viewed on the front end by visitors; anyone who can’t edit posts is redirected to the home page.
Display and exclude rules
Each rule is one location. A template appears if any display rule matches and no exclude rule matches. A template with no display rules does not appear anywhere.
| Group | Rule | Matches |
|---|---|---|
| Basic | Entire Website | Every page |
| All Singulars | Every single post, page or custom post | |
| All Archives | Every archive page | |
| Special Pages | 404 Page | The 404 page |
| Search Page | Search results | |
| Blog / Posts Page | The posts page | |
| Front Page | The front page | |
| Date Archive | Date archives | |
| Author Archive | Author archives | |
| WooCommerce Shop Page | The shop page | |
| Post Types | All Posts | Single items of that post type |
| All Posts Archive | That post type’s archive | |
| All Categories Archive | Archives of that taxonomy | |
| Specific Target | Specific Pages | Chosen posts, pages or terms |
The Post Types group lists every public post type and taxonomy on your site.
When several templates match
If more than one published template of the same type matches a page, the one with the most specific rule wins:
| Priority | Rule |
|---|---|
| 100 | Specific Pages |
| 50 | Any Special Pages rule |
| 40 | Taxonomy archive |
| 30 | Post type archive |
| 20 | All items of a post type |
| 10 | All Singulars, All Archives |
| 1 | Entire Website |
For example, with a site-wide header set to Entire Website and a second header set to Specific Pages → Contact, the Contact page uses the second header and every other page uses the first.
A template’s priority is the highest priority among its display rules.
Shortcode
Every template part has a shortcode, shown in the Shortcode box on the edit screen and in the admin list. Click it to copy.
[vlt_template_part id="123"]
The shortcode renders any template part type, ignoring display rules. Use it for Submenu and Custom templates, or to place a block inside other content.
Output:
<div class="vlt-tp-template" data-template-id="123">…</div>
Rendering in a theme
The plugin doesn’t change your theme’s header.php or footer.php. The theme asks for the matching template through a filter and decides what to do when nothing matches:
// header.php
$header = apply_filters( 'vlt_toolkit_tp_header', '' );
if ( $header ) {
echo $header; // phpcs:ignore WordPress.Security.EscapeOutput
} else {
get_template_part( 'template-parts/header/default' );
}
| Filter | Returns |
|---|---|
vlt_toolkit_tp_header | Matching header |
vlt_toolkit_tp_footer | Matching footer |
vlt_toolkit_tp_above_footer | Matching above-footer block |
vlt_toolkit_tp_404 | 404 template |
Each returns an empty string when no template matches. Otherwise it returns the Elementor content wrapped like this, with the template’s CSS already enqueued:
<div class="vlt-tp vlt-tp--header" data-template-id="123">…</div>
Listing templates
To fill a theme option or a select control with template parts of one type:
$submenus = vlt_toolkit_populate_template_by_type( 'submenu' );
// [ 123 => 'Services mega menu', 456 => 'Shop mega menu' ]
$all = vlt_toolkit_populate_template_by_type(); // every type
Technical details
| Post type | vlt_tp |
| Capability needed to create, edit or delete | manage_options |
| ACF field group | group_vlt_tp_settings |
| Meta fields | template_type, display_rules, exclude_rules, note |
The admin list has Display Rules, Note and Shortcode columns, the template type shown next to each title, and a dropdown to filter by type.