Title: Nested Shortcodes
Last modified: August 31, 2016

---

# Nested Shortcodes

 *  Resolved [Diego de Oliveira](https://wordpress.org/support/users/diegoliv/)
 * (@diegoliv)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/nested-shortcodes-7/)
 * Hi!
 * I have another question for you guys. Is it possible to use Shortcake and nested
   shortcodes?
 * An example: right, now, I’m trying to create a shortcode that is a wrapper for
   another shortcode (Tablepress [table] shortcode). It’s a shortcode that wraps
   the [table] shortcode into a div with some custom classes.
 * So, I’m using `do_shortcode` inside the function that renders the shortcode. 
   On the frontend, it works great, but at the backend we don’t get a visual representation
   of the shortcode, we just get the [table] shortcode string.
 * We’re using this piece of code:
 *     ```
       $html = '<div class="table-wrapper" id="'. $id .'" responsive="'. $responsive .'">';
       $html .= do_shortcode( '[table id="'. $id .'" responsive="'. $responsive .'"]' );
       $html .= '</div>';
   
       return $html;
       ```
   
 * This is the expected behavior for nested shortcodes, or maybe something particular
   to Tablepress’ `[table]` shortcode? Or am I doing something wrong?
 * Thanks!
 * [https://wordpress.org/plugins/shortcode-ui/](https://wordpress.org/plugins/shortcode-ui/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Daniel Bachhuber](https://wordpress.org/support/users/danielbachhuber/)
 * (@danielbachhuber)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/nested-shortcodes-7/#post-6989392)
 * > Is it possible to use Shortcake and nested shortcodes?
 * It’s not, no. Here’s the [existing Github issue](https://github.com/wp-shortcake/shortcake/issues/129).
   There likely won’t ever be nested UI for editing shortcodes, but shortcodes like
   Tablepress will need to produce their own UI for managing complex features.
 *  Thread Starter [Diego de Oliveira](https://wordpress.org/support/users/diegoliv/)
 * (@diegoliv)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/nested-shortcodes-7/#post-6989399)
 * Hi, Daniel,
 * I don’t have a problem with nested UI’s. The way shortcake works right now is
   great. I have created a set of fields that passes the necessary attributes to
   the `[table]` shortcode, so the issue is not with Shortcake’s UI. I just wanted
   to render the `[table]` shortcode inside the Shortcake preview (this is why I’m
   using `do_shortcode`), but it’s rendering `[table]` as a shortcode string instead.
   Using `do_shortcode` inside another shortcode is the expected approach from the
   Shortcodes API on Codex:
 * > If the enclosing shortcode is intended to permit other shortcodes in its output,
   > the handler function can call do_shortcode() recursively:
   >     ```
   >     function caption_shortcode( $atts, $content = null ) {
   >        return '<span class="caption">' . do_shortcode($content) . '</span>';
   >     }
   >     ```
   > 
 * This is basically what I’m doing.
 * So, the nested shortcode being rendered as a normal string inside a Shortcake
   preview is the defaul behavior? Just want to make sure we can’t do anything about
   it.
 * Thanks again for your help!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Nested Shortcodes’ is closed to new replies.

 * ![](https://ps.w.org/shortcode-ui/assets/icon.svg?rev=1130575)
 * [Shortcake (Shortcode UI)](https://wordpress.org/plugins/shortcode-ui/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/shortcode-ui/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/shortcode-ui/)
 * [Active Topics](https://wordpress.org/support/plugin/shortcode-ui/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/shortcode-ui/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/shortcode-ui/reviews/)

## Tags

 * [nested](https://wordpress.org/support/topic-tag/nested/)
 * [preview](https://wordpress.org/support/topic-tag/preview/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * 2 replies
 * 2 participants
 * Last reply from: [Diego de Oliveira](https://wordpress.org/support/users/diegoliv/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/nested-shortcodes-7/#post-6989399)
 * Status: resolved