WP Shortcode - Dynamic Shortcode
Updated over a week ago

The WP Shortcode Dynamic Shortcode (wp-shortcode) allows WordPress Shortcodes to be executed alongside Dynamic Shortcodes. Its major strength is the ability to use Dynamic Shortcodes as arguments to WordPress Shortcodes, thus making the WordPress Shortcodes itself dynamic.

Quick Example

Within a Dynamic Shortcode context, the following code

{wp-shortcode:gallery @ ids="1,2,3" size="medium"}​

is equivalent to the WordPress Shortcode:

[gallery ids="1,2,3" size="medium"]

Dynamic Arguments

Now, say that the gallery size should be dynamic and contained in an ACF field. With only WordPress Shortcodes, this is not possible, but it is with Dynamic Shortcodes using the WP Shortcode:

​{wp-shortcode:gallery @ ids="1,2,3" size={acf:gallery-size}}​

Say now that the gallery itself is also specified in an ACF Gallery field. The code is similar; we only need to keep in mind that the result is now a list, and we need to convert it to a string, as required by the gallery shortcode:

{wp-shortcode:gallery @ ids={acf:gallery|-implode(',')} size={acf:gallery-size}}

or equivalently:

{wp-shortcode:gallery @ ids={for:img {acf:gallery} {get:img} @sep=','} size={acf:gallery-size}}

Did this answer your question?