Skip to main content
Tokens
Updated over 4 months ago

From Dynamic Content for Elementor v3.0.0, Tokens have been deprecated and replaced by the more powerful and versatile Dynamic Shortcodes plugin.

Users of Dynamic Content for Elementor can benefit from a special version of the Dynamic Shortcodes plugin, included with their license, which automatically integrates and offers advanced features at no additional cost. More info...

A Token is a specially formatted chunk of text that serves as a placeholder for a dynamically generated value.
โ€‹

Syntax

[type:field-name:subfield-key|ID|filter1|filter2?fallback-text]
  • [ (required, open tag);

  • : field-name (required, native fields, and meta are supported);

  • : subfield-key (optional and multiple, if the field is Array or Object);

  • | ID (optional, int, if omitted will use the current post ID);

  • | filter (optional and multiple, you can manipulate results with PHP and WordPress functions);

  • ? fallback-text (optional, shown if the field value is empty or null);

  • ] (required, close tag).

Types

  • Post;

  • User;

  • Term;

  • Option;

  • WP_Query;

  • Query;

  • System;

  • Date;

  • Advanced Custom Fields;

  • JetEngine;

  • Meta Box;

  • Expression;

  • Form.

Examples

Post

  • [post:title|esc_html] - print current Post Title;

  • [post:_yoast_wpseo_metadesc] - print current Post Meta Description, a post meta field created by 3rd party plugin;

  • [post:_thumbnail_id|wp_get_attachment_url] - print the Feature Image URL;

  • [post:_thumbnail_id|wp_get_attachment_image_src(thumbnail)|reset] - print the Featured Image thumbnail URL of the current Post;

  • [post:ID|get_the_post_thumbnail(full)?] - print the current Post Featured Image through a core WP function with parameters or a placeholder image if the post hasn't got the Featured Image;

  • [post:date|strtotime|date_i18n("j F Y")] - print the current Post Date in a custom format;

  • [post:date|strtotime|sum(86400)|date_i18n("Y-m-d H:i:s")] - print the Post Date plus one day in default time format;

  • [post:ID|get_the_terms("category")|wp_list_pluck("name")] - print the name of the category (or categories) of Current Post;

  • [post:type:labels:singular_name] - print the Type Singular Label of the current Post;

  • [post:permalink] - print the unique URL of the current Post, use [post:guid] may be an alternative.

  • [post:post_parent|get_the_permalink] - to print the URL of the current post parent page.

  • [post:post_parent|get_the_title] - to print the title of the current post parent page.

WooCommerce Product

All WooCommerce tokens are available only if the Wocommerce plugin is enabled. All the previous Post Tokens are also compatible with Products.

  • [product:_price] - print current Product base Price;

  • [product:_sku] - print current Product SKU;

  • [product:_price|Woo-tshirt-logo] - print Product base Price of Product with a specific SKU.

Advanced Custom Fields

  • [acf:my_acf_field] - print the value of ACF Field, where "my_acf_field" is the name of the field in ACF settings, it works also for subfield in rows of ACF Repeater;

  • [acf:my_acf_field|123] - print the value of ACF Field of the Post with ID 123;

  • [acf:my_file:filesize|size_format(2)] - print the Human readable size (with 2 optional decimal) of an ACF File Field;

  • [acf:my_acf_field:title] - print the label of ACF Fieldset in its configuration;

JetEngine

  • [jet:field-key] - print the value of JetEngine Field, where "field-key" is the key of the field in JetEngine settings;

  • [jet:field-key|123] - print the value of JetEngine of the Post with ID 123;

Meta Box

  • [metabox:field-name] - print the value of Meta Box Field, where "field-name" is the key of the field in Meta box settings.

User

  • [user:first_name] - print logged User first name, or nothing if the page is viewed from a non authenticated visitor;

  • [user:last_name|concat('Mr ',true)] - print logged User last name with a prefix;

  • [user:nicename|trim?Anonimous] - print trimmed User Nicename, otherwise, if the user has no nicename or user does not exist will print "Anonymous";

  • [user:roles] - print logged in User Role, separated by a comma if multiple Roles.

Author

  • [author:display_name] - print the name of the author of the Current Post;

  • [author:ID|count_user_posts] - print the number of Posts written by the current Author, it accepts as a parameter the CPT name

Term

  • [term:name] - print Term name of Current Term or First Term of Current Post;

  • [term:description|wpautop] - print Term description with automatic paragraph;

  • [term:description|123] - print Term description of the Term with ID 123;

  • [term:count|123] - print Post count related to Term with ID 123;

  • [term:link|last] - print the URL to Term Archive of the last term of the current post;

  • [term:txtarea|artist] - print the value of an ACF field (like a Textarea) stored in Term of custom "artist" Taxonomy related to current Post;

  • [term:term_id|category|posts|reset|get_the_title] - print the Title of the last published Post in the same Taxonomy (Category);

  • [term:thumbnail_id|wp_get_attachment_url(full)] - return the URL of the Media in the Term Meta field which contains its ID.

Option

  • [option:elementor_version] - print the current version of the installed Elementor's plugin from WP system options;

  • [option:www_user_roles:editor:name|strtoupper] - print the uppercased name of Editor Role;

  • [option:home|wp_logout_url] - return to the direct Logout URL and return to the Homepage.

  • [option:page_id:field_id] - for a Metabox settings page option.

WP Query

  • [wp_query:posts] - print the id (or ids) of posts in the displayed page (like in archive);

  • [wp_query:query_vars:paged] - print the current pagination page number (return 0 on the first page).

Query

  • [query:user] - print the list of all Users (Display Names);

  • [query:user:editor] - print the list of Editor Users (or any other Role);

  • [query:user:customer|options("Guest")] - show a Customer list in the Options setting of a Select Form Field with also an empty value "Guest";

  • [query:term] - print the list of Terms (by default the Categories);

  • [query:term:post_tag] - print the list of Tags Terms (or any other Taxonomy);

  • [query:post] - print the list of the Posts (Titles);

  • [query:post|count] - print the number of published Posts;

  • [query:post:uncategorized] - print the list of the Posts without Category (or related to any other Term);

  • [query:page] - print the list of the Page (or any other Custom Post Type);

  • [query:product|options] - create the options list of all Products of your shop in a Select Form Field;

  • [query:post:_thumbnail_id] - print the list of the Featured Image Media ID of the Posts (or any other Meta Field);

System

  • [system:get:my_query_var] - print the variable stored inside $_GET, also compatible with POST, SESSION, COOKIE, and SERVER systems vars;

  • [system:cookie:my_favorite] - print the value stored inside a Cookie, also used for Add to Favorite Widget;

  • [system:server:REMOTE_ADDR] - print the IP address of the current visitor;

Date

  • [date:+1 month] - print the date of a month from today in WordPress default format;

  • [date|Y m d] - print the date of today in custom format;

  • [date:user:registered] - print the current User registration date in default WordPress format;

  • [date:post:date:+2 days|Y-m-d H:i:s] - print the current Post publish date + 2 days (optional) in standard DateTime format.

Custom var in a Loop

  • [ROW:var1|trim] - print the variable ROW inside widgets with your own HTML structure.

Expression

It supports nested Tokens

  • [expr:5+(8*2)/3] - execute a mathematic expression;

  • [expr:[post:my_num_val]*2] - execute a mathematic expression with Dynamic values (nested Tokens);

  • [expr:[post:my_num_val]+[post:my_num_val]*[acf:coeff|123]] - execute a mathematic expression with multiple Dynamic values.

Form

  • [form:my_field_id] - print the field value with ID "my_field_id" after form submission;

  • [form:all-fields] - print a list of all submitted fields;

  • [form:all-fields|!empty] - print a list of all submitted valued fields;

  • [form:pdf] - attach to Dynamic Email the PDF generated by PDF Generator for Elementor Pro;

  • [form:pdf:url] - print the URL of the PDF generated by PDF Generator for Elementor Pro;

  • [form:pdf:title] - print the Title of the PDF generated by PDF Generator for Elementor Pro;

  • [query:user|options] - return a formatted list compatible with Elementor PRO field options;

  • [query:term|options("Select a category")] - return a formatted list compatible with Elementor PRO field "Options" with an initial empty value;

  • [post:category|value] - prepare multiple fields (like the Post Categories) separating their values (term_id) by a comma, compatible with Elementor PRO field "Default Value".


Filters

As a filter, you can use all WP, PHP, and custom functions.

Some examples:

  • if the Token returns the string "Hello", with the filter strtoupper the final result will be "HELLO";

  • if the Token returns the Post ID, with the filter get_the_post_thumbnail will be printed its Featured Image.

How to add your own Custom filter

Add your function in your file functions.php, where the function name will be the filter name.
It has a unique parameter that contains the Token result, it may be a string, an array, an object, or null.

function my_custom_token_filter($data) {  
// do whatever you want
return $data;
}

Parameters

The Filters may accept also parameters, the Token's value is automatically passed to the function as the first parameter (or last for some function, like explode).

For example,

  • substr(0,3) gets the first 3 characters of the returned string;

  • get_the_post_thumbnail('full') gets the full image, not the thumb.

Multiple Filters

You can add multiple filters, which will be executed in concatenation based on their order. Type them separated by the "|" pipe:
โ€‹[post:title|sanitize_title|strtoupper|trim]

Did this answer your question?