Dynamic tag mods
Dynamic tags output data from various sources. In some cases, you might need to make modifications to the data before outputting them.
For example, a date dynamic tag outputs a date in plain format. Using a mod, you can convert that date to a format of your choice and then display it in the widget.
How to apply a mod to a dynamic tag
Once you add a dynamic tag to your dynamic content area, you can click on it to reveal the dynamic tag options. In the options area, you can press Add mod to reveal the available mods
There are various mods available which are suitable for different data types. The most relevant mods for the dynamic tag you’re editing are shown first.
This mods allows you to apply any WordPress supported format to dates.
You can view available formats in the WordPress documentation
For example, the format string:
l, F j, Y
formats the date to look like this
Friday, September 24, 2004
This mod allows you to extract the difference between the date provided by the dynamic tag and the current date. You can use this mod to create a more natural sentence like this:
This event starts in 3 days
This mod calculates the age based on a date dynamic tag e.g a field where the user picks the date of birth
This mod can be used to append text before the value of the dynamic tag. For example, to input currency
Similarly, this mod can be used to prepend text after the value of the dynamic tag
This mod capitalizes the value of the dynamic tag
Can be used to format plain numbers
Can be used to format and apply currency to plain numbers
This mod can be used to output static text if the value of the dynamic tag is empty
This mod can be used to output repeatable dynamic tags such as Taxonomy Terms in plain format by defining Item separator, last item separator, prefix, suffix
Conditional mods let you modify the value of the dynamic tag based on various conditions.
The available conditional mods are:
- Is empty
- Is not empty
- Is equal to
- Is not equal to
- Is greater than
- Is less than
- Is checked
- Condition: This is defined by the conditional mod that you appy
- Then: This defines the output if the condition is met
- Else: The defined the output if condition is not met
If you need to reference the dynamic tag output, you can type @value() in the Then or Else fields.
Example using conditional mods
We have a dynamic tag that outputs the number of followers as plain numbers
We can apply the Is equal dynamic tag to output the word “follower” in either singular or plain format depending on the value of the followers.