Total 5.6.1 introduced new “Dynamic Variables” which can be used when adding text within elements or in certain theme settings (such as custom page titles) to display non-static text. For example lets say you are creating a dynamic template and you want to display the page title with the date in the format “Page Title – Published Date” the dynamic variables will allow you to do this via the Heading element like such:
Available Dynamic Variables
Belo is a table showing the variables currently available in the theme and what they can be used to display.
|Variable name||Return value|
|Current post id.|
|Current post author name.|
|Current post publish date.|
|Current post last modified date.|
|Current post title.|
|Current post slug.|
|Current post rating.|
|Current post content (formatted/parsed).|
|Current post excerpt – returns the value of get_the_excerpt()|
|Current post url.|
|Current title (post or archives).|
|Current taxonomy name.|
|Current taxonomy term name.|
|Current taxonomy term id.|
|Number of posts in current archive.|
|Current post primary category.|
|Post primary term id.|
|Paged text for paginated pages.|
|ACF value where KEY is your acf field key or name.|
|Custom field value where KEY is your custom field key.|
|Current running count number when used within custom cards.|
|Icon defined under the Card Settings meta box.|
How to Add Custom Variables?
Yes, it’s possible to add your own custom replacement variables using the “wpex_replacement_vars” filter.
Let’s say there is a specific string of text you need to use in many places on your site, by defining a custom variable you can make sure that this string can be modified globally.
View the example snippet here.