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:
What Dynamic Variables are Available?
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 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.|
|Returns the post primary term id.|
|Displays the paged text for paginated pages.|
|Returns ACF value where KEY is your acf field key or name.|
|Returns Custom field value where KEY is your custom field key.|
How to Add Custom Replacement 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.