Understanding Keyargs in Dynamic Shortcodes
Dynamic Shortcodes provide an easy way to pass additional data and settings to the shortcode by using Keyargs.
What is Keyargs Syntax?
Keyargs is an easy syntax that allows you to pass additional data and settings to Dynamic Shortcodes. One Keyarg has a key and a value associated to it. The key is a simple text identifier (for example,
format) and the value can be virtually anything, depending on the requirements. The key and value are connected with an equal sign.
An example of a Keyarg is:
which associates the number 42 with the key id.
Usage of to Keyargs in Dynamic Shortcodes
Keyargs must be specified in a keyarg section, a keyarg section is a list of keyarg declarations separated by spaces. A keyarg section is introduced by the
All in all, if you have a shortcode like
we can add Keyargs like this:
If you want to add more than one, you can do
Omitting the Value
As a special case, a keyarg can omit the value. These are used to pass simple on/off flags to the Dynamic Shortcodes. A truth/on value is implied. For example, in
you are telling the ACF Dynamic Shortcodes field to format the field according to the ACF Field settings. You could use
but that is unnecessary.