Get Bricks

Dynamic Data

Use dynamic data to render all sorts of data from your WordPress database with Bricks.

For example: Featured image, post title, post date, author name, categories, tags, site title, all of your custom fields, etc.

You’ll most likely use dynamic data when creating templates in Bricks. Such as your blog post template, and custom post type templates (e.g. single property listing).

How to insert dynamic data

The dynamic data picker for text shows up when typing a “{” onto the canvas. You can also click the “bolt” icon in the settings panel to reveal it:

Dynamic data for non-text settings such as images, videos, etc. is available from the “Select dynamic data” dropdown menu in the panel settings.

Below you can see an Advanced Custom Fields gallery (named “Gallery”) rendered inside the Bricks image gallery element:

Since Bricks 1.3.5, all the dynamic data tags are available in all the elements that support dynamic data. This means that you may insert a gallery field (like an ACF gallery field type) inside a text element and it will be rendered as a set of img tags (using the filter :image), like so:

Custom Fields Integrations

You can render much more than just standard dynamic WordPress data. Bricks supports the most popular custom fields plugins such as:

This allows you to design templates for even the most complex custom post type layouts and data requirements.

Advanced Custom Fields

Bricks integrates with all the ACF and ACF Pro fields, except the Flexible Content. The fields will be listed in the Dynamic Data dropdown inside of the Bricks builder so you could use them while building your pages and templates with Bricks.

The Relationship (including the bidirectional implementation) and the Repeater field types are also available inside the Query Loop builder so you could loop through the output of these fields while rendering the sub-fields as dynamic data.

Meta Box

Bricks is compatible with the Meta Box Post Types, Taxonomies, Custom Fields and Relationships. Regarding the Custom Fields, Bricks will list the fields in the Dynamic Data dropdown inside of the Bricks builder. These tags will be rendered properly in the frontend according with the custom fields contents.

The Group field (when cloneable) and the Relationships will also be available inside of the Query Loop builder so you could iterate through these values and render the sub-fields as dynamic data.

Crocoblock JetEngine

Bricks is compatible with Crocoblock JetEngine Post Types, Meta Boxes (Custom fields), Taxonomies, Relations, and Options pages. The Custom Content Types (CCT) are not yet integrated.

Bricks integration with the JetEngine plugin makes the custom fields available as dynamic data inside the Bricks builder.

Bricks also integrates with the JetEngine Relations and Repeaters to feed the Bricks builder query loop.

Standard WordPress data

By default, you may use the following dynamic data tags.

Post fields

The following fields are related to the posts or custom post types.

{post_title} – Returns the post title
{post_id} – Returns the post ID
{post_url} – Returns the post URL
{post_date} – Returns post published date
{post_modified} – Returns post modified date
{post_time} – Returns post publish time
{post_comments_count} – Returns number of comments
{post_content} – Returns post content (Gutenberg editor)
{post_excerpt} – Returns the post excerpt
{read_more} – Renders an anchor tag (link) to the post with the label “Read more”
{featured_image} – Renders an image tag with the featured image

These fields support the following dynamic data filters:

{post_title:link} – Renders the post title as a link to the post
{post_title:link:3} – Same as before but the title is limited to 3 words
{post_title:link:newTab} – Open post title in new tab (@since 1.4)
{post_date:human_time_diff} – outputs the date difference in a human readable format such as “1 hour”, “5 mins”, “2 days” (Bricks 1.4)
{post_excerpt:55} – Limit post excerpt to 55 words. Using the “:” followed by a number limits the output to that number of words
{featured_image:medium_large} – Renders an image tag with the featured image of size medium_large (defaults to thumbnail size)
{featured_image:large:link} – Renders an image tag with the featured image of size large wrapped by an anchor tag to the post

Taxonomies

The following dynamic data tags render a list of the taxonomy terms assigned to a post, where each term is wrapped by a link to the term archive:

{post_terms_category}
{post_terms_post_tag}
{post_terms_my_taxonomy_slug}

If you’re already using a link around your element, you can disable the terms’ links output using the bricks/dynamic_data/post_terms_links filter.

Terms

The following dynamic data tags render data related to taxonomy terms.

{term_id} – Renders the term ID
{term_name} – Renders the term name
{term_url} – Renders the term archive link
{term_description} – Renders the term description
{term_meta:my_term_meta_key} – Renders the “my_term_meta_key” meta value

Author Fields

{author_name} – Returns the post author name
{author_bio} – Returns the post author biographical info
{author_email} – Returns the post author email
{author_website} – Returns the post author website
{author_avatar} – Returns the post author avatar as an image tag (text) or an image url (link)

These fields support dynamic data filters, like the following:

{author_bio:20} – Post author biographical info limited to 20 words
{author_email:link} – Post author email rendered as a link
{author_website:link} – Post author website rendered as a link
{author_avatar:200} – Post author avatar image tag limited to the width/height of 200px

Current Date fields

You can render the current date through dynamic data.

{current_date} – Returns the current date with the format defined at WordPress > Settings > General > Date Format

You may specify a different date format using the PHP date format, for example:

{current_date:Y}
{current_date:Ymd}
{current_date:Y-m-d}
{current_date:Y.m.d}
{current_date:Y/m/d}
{current_date:Y m d}
{current_date:g:i A}

Site & Archive fields

{site_title} – Returns site title as defined in the WordPress settings > General > Site Title
{site_tagline} – Returns site tagline as defined in the WordPress settings > General > Tagline
{archive_title} – Returns archive title
{archive_title:context} – Add context to the archive title
{archive_description} – Returns archive description (author, post type or term)

Since Bricks 1.3.5, it is possible to get dynamic data from the URL parameters like so:

{url_parameter:my_key} – Returns the value of the my_key parameter in the url (https://mydomain.pt/?my_key=value)

User profile fields

{wp_user_id} – Returns logged in user ID
{wp_user_login} – Returns logged in user username
{wp_user_email} – Returns logged in user email address
{wp_user_url} – Returns logged in user website
{wp_user_nicename} – Returns logged in user nicename
{wp_user_description} – Returns logged in user biographical info
{wp_user_first_name} – Returns logged in user first name
{wp_user_last_name} – Returns logged in user last name
{wp_user_display_name} – Returns logged in user display name
{wp_user_picture} – Returns logged in user avatar image tag or url
{wp_user_meta:my_user_meta_key} – Returns logged in user “my_user_meta_key” meta value

Native WordPress custom fields

To render your very own custom field entries you just have to prefix them with cf_. If your custom field name is “phone_number” you’d use to render this custom field on the frontend.

Your phone_number custom field entry should also be available in the dynamic data picker dropdown under “Custom fields”.

Advanced

Bricks 1.4 introduces the echo tag to render the output of any PHP function:

{echo:my_custom_function} – Echoes the value of the PHP function my_custom_function()

It accepts arguments, with or without single quotes, like so:
{echo:get_the_date('Y-m-d', 55)} – Echoes the date of the post 55 formatted to Y-m-d

Please note that the echo tag does not support double quotes and that the custom PHP function should return the value (do not echo the value inside of the custom function).

WooCommerce

When the WooCommerce plugin is installed and active, you’ll get access to an extra set of Dynamic Data tags related to the products and orders. Please refer to the WooCommerce builder article for more details.

Filters

In order to change the output of some Dynamic Data tags it is possible to use the following filters

  • :numeric value – When used on a text field, it trims the content to the number of words specified (e.g. Use dynamic data to render all sorts of data from…). When used with an avatar field like author_avatar it specifies the width/height of the avatar image
  • :context or :prefix – Add context to the archive title
  • :image – Outputs the field as an image tag, e.g. <img src="https://..." />
  • :link – Output the field as an anchor tag, e.g. <a href="https://...">value</a>
  • :newTab – Sets the link to open in a new tab
  • :tel – The URL of the anchor will be formatted as a telephone number,
    e.g. <a href="tel:+123456789">+123456789</a>
  • :text value – Depending on the context it could mean the following:
    • User or term custom field meta key
    • The URL parameter key
    • Post terms separator
    • Date format
    • Image size slug (e.g. thumbnail, or full)
    • The echo tag function name
  • :value – Outputs the value instead of the label. Useful for comparing choices field types like Metabox checkbox list, etc. inside element conditions (@since 1.5.7)
  • :raw – Skip parsing dynamic data tag (@since 1.6)
  • :url – Return URL from post ID (@since 1.6). Useful to return URL for file field, etc.

Bricks hooks related to Dynamic Data

bricks/dynamic_data/exclude_tags – exclude a list of tags from the Bricks dynamic data logic

bricks/dynamic_data/replace_nonexistent_tags – Disable the default Bricks behavior of replacing the non-existent dynamic data tags with an empty string