Title: Shortcode Recursion Bug
Last modified: May 5, 2026

---

# Shortcode Recursion Bug

 *  [codesmith32](https://wordpress.org/support/users/codesmith32/)
 * (@codesmith32)
 * [1 day, 21 hours ago](https://wordpress.org/support/topic/shortcode-recursion-bug/)
 * Hey!
 * Just a friendly developer reviewing the code here 🙂
 * I think I found a recursion issue (I’ll be honest, I haven’t installed it just
   yet). It looks like you have some code in place to prevent the same shortcode
   from running, but I don’t see anything in place for preventing multi-step recursion.
   Also, I think the code that’s there would fail to save it after rendering a different
   sub-shortcode.
 * More specifically, here’s the code I’m seeing:
 *     ```wp-block-code
               // Prevent same shortcode nested loop        if( self::$current_shortcode == $shortcode[ 'name' ] ){            return '';        }        self::$current_shortcode = $shortcode[ 'name' ];...        self::$current_shortcode = false;        return $sc_content;
       ```
   
 * You probably actually want to make `self::$current_shortcode` an array that you
   push to/pop from, and then do an `in_array()` check, rather than using a single
   value. Otherwise, if shortcode A contains B, and shortcode B contains A, this
   wouldn’t catch the recursion. The `= false` here also fails to restore the previous
   value. So, if shortcode A contains shortcode B followed by shortcode A, `self::
   $current_shortcode` is `false` by the time the nested A is reached.
 * Thanks for your work though! I’ll probably install this soon! (Albeit, I’ll just
   be careful with recursive shortcodes 😉 )
    -  This topic was modified 1 day, 21 hours ago by [codesmith32](https://wordpress.org/support/users/codesmith32/).
    -  This topic was modified 1 day, 21 hours ago by [codesmith32](https://wordpress.org/support/users/codesmith32/).

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fshortcode-recursion-bug%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * ![](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/)

 * 0 replies
 * 1 participant
 * Last reply from: [codesmith32](https://wordpress.org/support/users/codesmith32/)
 * Last activity: [1 day, 21 hours ago](https://wordpress.org/support/topic/shortcode-recursion-bug/)
 * Status: not resolved