Title: Shortcode Recursion
Last modified: June 25, 2021

---

# Shortcode Recursion

 *  [David Goring](https://wordpress.org/support/users/dg12345/)
 * (@dg12345)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/shortcode-recursion/)
 * I’ve got xdebug installed and it outputs the trace which will include the args
   of called functions.
 * This is causing a recursion loop when an error occurs in the output of a shortcode,
   as the shortcode itself is outputted as the arg of the trace.
 * Give this the result of a shortcode could be returned by accident and personally
   I cannot think of any reason to have recursion via the shortcodes.
    Could the
   shortcode processor keep track of the parent code(s) and not process them if 
   they appear in the shortcode output

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

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/shortcode-recursion/#post-14604307)
 * Well, don’t let any errors occur then 😛
 * But seriously, instead of messing with the processor, I think it’d be better 
   to pre-process the output to somehow escape the shortcode in debug output so 
   that it is not picked up by the processor to start with. Converting square brackets
   only in debug output into HTML entities might be a way to escape shortcodes.
 * The challenge will be to pre-process output after debug output but before shortcode
   processing. The correct priority arg for the “the_content” filter should do the
   trick, but I’m unsure of how/when debug output happens. In any case some sort
   of output buffering and selective escaping should work.
 *  Thread Starter [David Goring](https://wordpress.org/support/users/dg12345/)
 * (@dg12345)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/shortcode-recursion/#post-14626749)
 * My own fix will likely be to use the shortcode filters to disable and enable 
   aspects of xdebug, before and after the shortcode has run
 * html entities are unlikely to work as the shortcode processor looks for escaped
   square brackets.
 * However my reason for adding it here is that it should not be able to cause a
   recursion loop ever, whether its from a error report of from someone outputting
   content

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

The topic ‘Shortcode Recursion’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [David Goring](https://wordpress.org/support/users/dg12345/)
 * Last activity: [4 years, 11 months ago](https://wordpress.org/support/topic/shortcode-recursion/#post-14626749)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
