Dynamic Templates

Dynamic Templates let you create reusable content fragments that can be filled with different values depending on the context in which they’re used. Once the feature is activated under Greyd.Suite → Features, a new post type called Templates appears in the main admin menu.

Depending on the active theme, either a custom block (in the Greyd Theme) or a Visual Composer element with shortcode (in the classic Greyd.Suite Theme) becomes available. In both cases, dynamic tags for contextual content are unlocked throughout the Block and Site Editor.

Templates are non-public posts meant to be inserted into other content areas across the site. Inside a template, blocks can be marked as dynamic. These blocks are later filled with content when the template is used, allowing one structure to serve multiple use cases.

Templates Post Type

Screenshot of the Dynamic Templates page, explained in the paragraph below

The “All Templates” screen shows a familiar list of all template posts. This list includes standard WordPress controls like sorting by title or date and filtering by category. A unique “Usage” column is also added. It shows how often each template is used across the site. Clicking the info icon in that column opens a modal with detailed references to the pages or posts where the template appears. Keep in mind that deleting a template in use will remove that content from the frontend.

To make working with similar systems easier, the submenu items under the Templates post type also include direct links to other content structures: the Site Editor’s WordPress Templates and Template Parts, and the custom Patterns list. This helps bridge the gap between dynamic fragments, structural templates, and design patterns.

Screenshot of the editing view of a Template, explained in the next paragraph.

When you create or edit a template, the interface works like editing a regular post. However, templates don’t have a public URL or preview, since they render differently depending on context. Templates can be assigned to categories, which helps manage larger sets, but categories don’t have any effect on template behavior.

While editing, all blocks are available and can be used freely. Most of them include an extra panel labeled Dynamic Elements in the right sidebar. This is what makes the content inside the block replaceable later. Within that panel, each modifiable attribute of the block can be turned into a dynamic field. Once activated, you’ll see an input for a Field Name — this acts as a reference key. The value is auto-generated but can be renamed. This name is used to link the template block’s content to an editable field when the template is inserted elsewhere.

Screenshot with the Dynamic Elements in the sidebar, as described before

If you assign the same name to multiple elements, they’ll all receive the same value later. However, if you rename a field after the template is already in use somewhere, the connection breaks and the previously set dynamic content won’t show up anymore.

Block: Template

The Template block allows you to embed the contents of any previously created Dynamic Template into any page or post. This makes it easy to reuse structured content while retaining the ability to customize individual pieces through dynamic fields.

Once the Dynamic Templates feature is activated, you’ll find a custom block called Template in the block inserter under the “Greyd” category. To indicate it’s dynamic features, it has a purple block icon, it shares the color with the default Core blocks like template parts. You can insert it by clicking the + icon, by typing /template into a paragraph block, or by using the shortcut ++ followed by the title of an existing template. After insertion, a placeholder appears prompting you to select a Dynamic Template. This can also be done in the sidebar.

Screenshot of the Template selection placeholder, described in the previous paragraph

Once a Dynamic Template is selected, the block renders its contents directly in the editor preview. These are virtual blocks: they behave like real blocks, show up in the block list view, and can be selected — however, they are not stored in the post content. Instead, the Template block only saves a reference to the selected Dynamic Template and any overridden dynamic values.

Screenshot of a sample Dynamic Template with its content rendered in the editor, as described in the previous paragraph

Elements marked as dynamic during template creation or editing are editable here. Most non-dynamic blocks can’t be modified — instead, selecting them will activate the Template block wrapper. Dynamic blocks, however, can be clicked to open rich text inputs directly in the preview. Sidebar inputs are disabled to avoid accidental edits; they’re blocked with an overlay message. RichText editing also supports contextual Dynamic Tags, which allow you to insert values like post titles or metadata, especially useful in query loops or template-based contexts.

The block toolbar provides quick actions: the “Reload” icon refreshes the template preview (useful if changes were made in another tab), “Edit template” opens the editing screen in a new tab, and “Reset” clears all overridden dynamic values, reverting to default.

Block Settings

In the block sidebar, the Select Template section lets you choose or change the current dynamic template. If a change is made, the editor tries to keep dynamic values matched by field name and type. If multilingual support is active, a translation hint appears if a fitting translation exists.

The Display Post option allows you to render the dynamic template using the context of any post. By default, it uses the current post context. When switched, it updates all dynamic values according to the selected post. This is essential for previewing how a template behaves with different content.

In the Dynamic Elements panel, you’ll find a list of all editable fields defined in the template. Each is labeled with its field name, input type, and the associated block type. A reset icon is available to revert any changes to the default state. If two elements have the same name, they are automatically filled with the same content and will not be listed individually as dynamic fields. This has the great advantage that you can easily copy template elements for mobile optimization without the editor having to fill them several times later.

The Template block also supports Animations and has an Advanced panel that offers the default HTML anchor setting, additional CSS classes, hide block per breakpoint and inline styling. In addition to these, there’s also a toggle to use the template slug instead of the ID as reference, which is useful for better portability.

Context of Dynamic Templates

Dynamic Templates always operate within a specific context that defines where their dynamic values are pulled from. By default, this context is the post or page in which the Template block is used. Dynamic Tags inside the template will then reference values from this post, such as the title, date, author, or custom fields (see also the Post Types documentation).

However, you can override the context to render different content with the same template — even multiple times on the same page. One way is by using the Display Post setting in the template block’s sidebar. This lets you select a specific post from which dynamic values will be pulled, regardless of where the block is placed.

Another method is to place the Template block inside a Query Loop. If used inside a “Post Template” or “Post Slider,” the template will dynamically adjust its context based on the current post in the loop. As the Query Loop cycles through posts, the template is filled with the corresponding values for each one.

When used inside WP Templates or Template Parts in the Site Editor — such as Home, Single, Archive, or 404 templates — the Template block automatically inherits the context of the active WP Template. In this case, dynamic content is determined by the template’s assigned post type or query output.

If you’re using the classic Greyd.Suite Theme, where the Site Editor is not available, context is handled differently. Here, so-called “System Templates” define their context via naming conventions and template type. This allows dynamic rendering even without the full block-based editing experience.

For an in-depth explanation of how dynamic values are tied to context and how to fine-tune them, refer to the Dynamic Tags documentation.

Additional Editor Tools

To streamline working with Dynamic Templates, several additional tools are integrated directly into the editor interface.

Create Dynamic Template

One key feature is “Create Dynamic Template”, which lets you convert any selected block — or group of blocks — into a new Dynamic Template. You’ll find this option in the context menu (the three dots) of the block toolbar.

Screenshot highlighting the creation of a Dynamic Template through the context menu in the block toolbar, as explained in the previous paragraph

Selecting it opens a modal where you can define a name and optionally assign categories. You can also choose to “Enable content overwrites”, which activates dynamic fields for all compatible block attributes (see also: Dynamic Elements). Once added, the selected blocks are replaced by a “Template” block that is already linked to the newly created Template.

Screenshot of said modal to add the New Dynamic Template

Detach Dynamic Template

The “Detach Dynamic Template” tool lets you reverse this process. It’s available in the context menu of any “Template” block. Selecting this option will convert the block back into regular blocks within your post or page. All existing dynamic values will be applied to the detached blocks, while the remaining dynamic bindings are removed.

Screenshot highlighting the Detach Dynamic Template function in the context menu of the toolbar as stated in the previous paragraph

When working with Templates and pages in parallel — e.g., in separate tabs — updates are synced automatically. Dynamic Templates use WordPress’ heartbeat system to detect external changes. This ensures that when editing a page, you can simply hit “Reload Template” in the toolbar to see changes made elsewhere — without needing to refresh the entire editor. Additionally, dropdowns that list available Templates update in real time whenever new Templates are created.

Dynamic Tags

Dynamic Templates also introduce Dynamic Tags across the entire Post and Site Editor. These allow you to pull contextual data from your post, query, or global site settings. While tightly integrated with Templates, these tags can also be used independently. Full details are covered in the Dynamic Tags documentation.

Use template slug

Finally, under “Advanced” in the Template block sidebar, there’s a toggle labeled “Use template slug”. By default, a Template is referenced by its database ID. With this option enabled, the block instead references the Template by its slug (the URL-friendly name). This change is invisible to visitors, but can simplify template handling when using Global Content. If you need stricter control, you can globally enforce this behavior using the greyd_dynamic_block_use_reference filter, which supports four modes:

PHP
/**
 * Example: Force all templates to use slug reference.
 */
add_filter( 'greyd_dynamic_block_use_reference', function() {
    return 'forceSlug';
} );

Possible values for the filter:

  • "ID" (default): uses ID, toggle is available.
  • "slug": uses slug, toggle is available.
  • "forceID": enforces ID, toggle is hidden and existing blocks are converted.
  • "forceSlug": enforces slug, toggle is hidden and existing blocks are converted.

Video

You are currently viewing a placeholder content from Vimeo. To access the actual content, click the button below. Please note that doing so will share data with third-party providers.

More Information