USP Pro is equipped with a powerful set of shortcodes that enable vast configurational possibilities, including wrapping a shortcode with a shortcode, aka nested shortcodes. In this post, we’ll provide an example and a quick solution for getting WordPress to recognize and execute shortcodes within shortcodes when included in post/page content and/or widgets.
Enable nested shortcodes
Super easy, just add the following lines to your theme’s
// execute shortcodes in content and widgets add_filter('the_content', 'do_shortcode', 10); add_filter('widget_text', 'do_shortcode', 10);
That’s all there is to it. The first
add_filter enables nested shortcodes in post/page content, and the second
add_filter enables same in widgets. Feel free to remove either if not needed. Once that code is in place, you can do cool stuff like use shortcodes to display forms only to logged in users, like so:
Pro Tip: any
[usp_form] that you want to display via shortcode must be published (not draft or pending).