Design System is here - Read the release post

Learn GeneratePress

Dynamic Tags

Dynamic Tags are the ultimate no-code solution for showcasing dynamic content across your entire site. Whether you’re working with standard content or building specialized sites with custom content types and fields, Dynamic Tags has you covered.

With GenerateBlocks, you can style and lay out your dynamic data just like any regular content—giving you the flexibility to create stunning, personalized experiences without breaking a sweat.

What are Dynamic Tags

Dynamic Tags allow you to directly insert and preview dynamic content from your database straight inside the Block Editor. Each Tag:

  • displays a specific piece of data eg. a title, image or some post meta.
  • has customziation options eg. adds a link or sets an image size.
  • uses a common syntax with optional parameters

There are 25 Tags to work with, and each of them comes with its own custom options to set different arguments.

Dynamic Tag syntax

{{dynamic_tag_name parameter1:value1|parameter2:value2 ...}}

An example of a dynamic tag without parameters:

{{post_title}}

An example of a dynamic tag with parameters:

{{post_title link:post}}

An example of a dynamic tag with multiple parameters separated by a pipe ( | ):

{{term_list link:term|tax:category|sep:,}}

Creating and adding Dynamic Tags

Adding dynamic tags is completed in 4 simple steps.

  1. Open the Dynamic Tag Editor
  2. Choose the Dynamic Tag
  3. Set the Tag Parameters
  4. Insert the Dynamic Tag

1. Open the Dynamic Tag editor

A Dynamic Tag can be inserted anywhere you see the Open Dynamic Tag editor button:

Open Dynamic Tag editor

The button can be found in the most commonly required places:

  • the Block Toolbar for inserting into the blocks content
  • the Block Toolbar Link field for adding dynamic links to a button block
  • the Block Settings fields such as Image URL and Links

2. Choose a Dynamic Tag

Select the Dynamic Tag from the drop down modal

3. Set the Dynamic Tag parameters

adjust the Dynamic Tags returned value by setting the parameters

3.1 Required to render

This option controls what happens when the dynamic tag returns no value.

If enabled, the block will be displayed only when the dynamic tag has a value. If no value is returned, the block will be removed.

This applies to any GenerateBlock where the dynamic tag is used in its content, a block setting (e.g., image URL), or an Advanced > Data Attribute (Pro only).

4. Insert the Dynamic Tag

click the Insert Dynamic Tag but to add the tag to the Block.

Editing Dynamic Tags

A block can contain one or many dynamic tags. You can re-open the dynamic tag editor modal on any block to examine and edit existing tags attached to the block or add additional tags.

Open Dynamic Tag editor

Dynamic Tag Preview and Editing Modes

Blocks containing Dynamic Tags can have one of two states in the editor: Preview mode and Edit Mode.

Block Preview Mode

Blocks containing a Dynamic Tag default to PREVEW Mode. This is indicated by the highlighted preview toggle in the blocks toolbar. You can toggle between Preview and Edit.

Whist in Preview mode the:

  1. the blocks content cannot be edited
  2. the actual dynamic data value may* be displayed

Preview is not working

It may not be possible for GenerateBlocks to retrieve the dynamic data within the block editor. This may be a limitation on the data source eg. no REST API support. Check the front end to see if it is working.

Block Edit Mode

Edit mode is the alternate state for a block containing a dynamic tag and is indicated by the PREVIEW tag in the toolbar. You can toggle between Preview and Edit.

In Edit Mode:

  1. the blocks content can be edited
  2. dynamic tags are displayed instead of their values
  3. you can insert additional tags in the cursor position

Multiple Dynamic Tags and mixed content

A Blocks content can contain multiple Dynamic Tags in addition to static content. Allowing you to combine text outputs from multiple sources. A simple example would be an author byline:

Written by: tom on February 1, 2025 8:18 pm

To do this:

  1. add a Text Block and type in the prefix text eg. Written by:
  2. open the Dynamic Tag editor from the blocks toolbar
  3. add the Dynamic Tag for the author_meta key:display_name
  4. switch the block state to Edit Mode, add the additional static text eg. on
  5. open the Dynamic Tag editor from the block toolbar
  6. add the Dynamic Tag for the post_date

Whilst in edit mode you will see something like this:

Written by: {{author_meta key:display_name}} on {{post_date}}

Using the dynamic data and static content together allows

Manually adding tags

The Dynamic Tag editor modal is a convenience tool allowing you build and edit tags with a user friendly interface. But that is all it does. You can if you wish manually type or copy and paste a Dynamic Tag into the blocks content or block setting.

Dynamic Tags and inline event handlers (on*)

Dynamic Tags resolve almost everywhere—block content, links, image sources, and data attributes. The one place they can’t be used is inside an inline event handler: any attribute whose name starts with on, such as onclick, onmouseover, or oninput. The same applies to srcdoc.

What you wrote:   onclick="track('{{post_title}}')"
What renders:     onclick="track('')"

Why Dynamic Tags don’t run in event handlers

An inline event handler runs its value as JavaScript, and the browser decodes the attribute before the JavaScript engine reads it. That means there’s no way for GenerateBlocks to escape a dynamic value that the browser won’t simply undo a moment later. A resolved value containing a quote—or one passed to something like eval(), setTimeout(), or new Function()—could break out of the handler and run as code.

The safe alternative: read the value from a data attribute

The fix is to stop placing the dynamic value inside the handler’s code and instead read it as data when the handler runs. Put the Dynamic Tag in a data-* attribute—which resolves safely—and reference that attribute from your handler. Both attributes are added to the block under Advanced > HTML Attributes (GenerateBlocks Pro):

data-my-title="{{post_title}}"
onclick="track( this.dataset.myTitle )"

Here the Dynamic Tag lives only in data-my-title, so it resolves normally; the onclick contains no Dynamic Tag, so it’s left exactly as you wrote it. When the element is clicked, this.dataset.myTitle hands your function the attribute’s value as a plain string. Because that value is read as data and never becomes part of the JavaScript source, it can’t break out or run as code—even a title full of quotes or <script> tags is harmless.

A note on inline handlers: an inline on* attribute can only be saved by users who are allowed to post unfiltered HTML—typically administrators and editors on a single site. This is standard WordPress behavior. If your handler is stripped on save, or you’d rather have one script serve many elements, drop the inline handler and attach a delegated listener instead:

document.addEventListener( 'click', function ( event ) {
    const el = event.target.closest( '[data-my-title]' );

    if ( el ) {
        track( el.dataset.myTitle );
    }
} );

Either way, the Dynamic Tag resolves into the data attribute (for example data-my-title="My Post Title") and your code reads it from there—delivered as a value, never executed as markup or script.

Developers Docs