Title: Nested shortcode not working correctly
Last modified: December 27, 2023

---

# Nested shortcode not working correctly

 *  [timb111](https://wordpress.org/support/users/timb111/)
 * (@timb111)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/nested-shortcode-not-working-correctly/)
 * Are nested shortcodes supported? I read [your comment from an old thread](https://wordpress.org/support/topic/nested-shortcodes-dont-work/#post-14921806)
   where you said “In version 5.0+ the shortcode content can have another “shortcoder
   shortcode” there is no restriction.” but in my case there’s a bug where the 2nd
   shortcoder closing tag is printed on the web page.
 * I’ve created 2 shortcodes. Shortcode 1 is called “sc-test-nest-1” and contains“
   SC1 content and $$enclosed_content$$”. Shortcode 2 is called “sc-test-nest-2”
   and contains “SC2 content”.
 * In a blank page I’ve inserted this shortcode “[sc name=”sc-test-nest-1″][sc name
   =”sc-test-nest-2″][/sc][/sc]”.
 * The result should be “SC1 content and SC2 content”, but it is producing “SC1 
   content and SC2 content[/sc]”.
 * Can you please advise on whether nested shortcodes should be working, and how
   I can fix this?

Viewing 1 replies (of 1 total)

 *  Plugin Author [vaakash](https://wordpress.org/support/users/vaakash/)
 * (@vaakash)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/nested-shortcode-not-working-correctly/#post-17303744)
 * Hi [@timb111](https://wordpress.org/support/users/timb111/),
 * When there are nested shortcodes of the same name then WordPress has challenge
   in parsing which is parent and which is child.
 * `[sc name="nest-parent1"][sc name="nest-child1"][/sc][sc name="nest-child1"][/
   sc][/sc]`
 * In this example, parser does not know [/sc] closes which shortcode. A shortcode
   can execute even without [/sc]
 * The solution should be to use it like below. This would work only for one level
   nesting.
 * `[sc name="nest-parent1"][sc name="nest-child1"][sc name="nest-child1"][/sc]`
 * Since the open and close tags are same there is restriction. If you are using
   shortcode other than `[sc`] then everything will work as expected.
 * Thanks,
 * Aakash

Viewing 1 replies (of 1 total)

The topic ‘Nested shortcode not working correctly’ is closed to new replies.

 * ![](https://ps.w.org/shortcoder/assets/icon.svg?rev=2222236)
 * [Shortcoder — Create Shortcodes for Anything](https://wordpress.org/plugins/shortcoder/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/shortcoder/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/shortcoder/)
 * [Active Topics](https://wordpress.org/support/plugin/shortcoder/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/shortcoder/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/shortcoder/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [vaakash](https://wordpress.org/support/users/vaakash/)
 * Last activity: [2 years, 3 months ago](https://wordpress.org/support/topic/nested-shortcode-not-working-correctly/#post-17303744)
 * Status: not resolved