Back to Community

How to Use Nested Shortcodes in Shortcodes Ultimate Attributes

Content

Many users of the 'WP Shortcodes Plugin — Shortcodes Ultimate' want to create powerful, dynamic content by nesting one shortcode inside another. A common request is to use the su_permalink shortcode to generate a URL dynamically and then pass that URL into the data attribute of the su_qrcode shortcode.

This technique, known as using nested shortcodes, is documented by the plugin's team. The official method involves replacing the square brackets ([, ]) of the nested shortcode with curly braces ({, }) and using single quotes (') instead of double quotes for the attributes. For example:

[su_qrcode data="{su_permalink id='706'}" size="300" align="center" background="#ffffff"]

However, as seen in user reports, this does not always work as expected. The primary reason for this is that not every shortcode supports having other shortcodes within its attributes. The ability to nest shortcodes is dependent on how each individual shortcode was programmed. The su_qrcode shortcode, along with several others in the plugin, may not currently support this functionality.

How to Check and Troubleshoot

If you encounter an issue where a nested shortcode isn't working, follow these steps:

  1. Verify Support: First, assume the shortcode may not support nesting. The plugin's documentation specifically states that "some plugin shortcodes allow using other shortcodes in their attributes." This implies that it is not a universal feature across all shortcodes.
  2. Syntax Check: Double-check your syntax. Ensure you are using the correct curly braces and that all attribute values within the nested shortcode are enclosed in single quotes.
  3. Alternative Approach: If the nested shortcode fails, a reliable workaround is to use a custom function in your theme's functions.php file or a code snippets plugin. You can create a custom shortcode that outputs the desired permalink, which can then be used within the su_qrcode shortcode.

While the nested shortcode feature is powerful, its availability is limited to specific shortcodes within the plugin. For advanced dynamic content, exploring custom code solutions often provides the most flexibility and reliability.

Related Support Threads Support