Title: Stop Shortcodes from Executing inside code block
Last modified: September 20, 2024

---

# Stop Shortcodes from Executing inside code block

 *  Resolved [Zack Pyle](https://wordpress.org/support/users/zackpyle/)
 * (@zackpyle)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/stop-shortcodes-from-executing-inside-code-block/)
 * Can you please make it so shortcodes won’t execute inside of the block? The only
   way I can add a shortcode to the page without it executing currently is to use
   the default code block.
 * Thanks!

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

 *  Plugin Author [Kevin Batdorf](https://wordpress.org/support/users/kbat82/)
 * (@kbat82)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/stop-shortcodes-from-executing-inside-code-block/#post-18029375)
 * Yeah good idea on that. I’ll look into it this week and follow up here. Thanks
   Zack.
 *  Plugin Author [Kevin Batdorf](https://wordpress.org/support/users/kbat82/)
 * (@kbat82)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/stop-shortcodes-from-executing-inside-code-block/#post-18037402)
 * i have a solution for this but deciding on whether I should make it opt-in via
   a checkbox or not. Will have something by the weekend though.
 * For the meantime, you can use [ and ](https://codex.wordpress.org/and) which 
   will signal to WordPress to escape the shortcode and not run it. But if I don’t
   make it opt in then you’ll have to remove the extra [ (which is why I’m considering
   making it opt in)
 *  Thread Starter [Zack Pyle](https://wordpress.org/support/users/zackpyle/)
 * (@zackpyle)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/stop-shortcodes-from-executing-inside-code-block/#post-18038359)
 * [@kbat82](https://wordpress.org/support/users/kbat82/) Thanks! But it stripped
   out your meantime solution. Can you screenshot it instead?
   And yeah, I think 
   making it a checkbox of “Stop Shortcode Execution” for each block is probably
   smart. It also is backwards compatible.
 *  Plugin Author [Kevin Batdorf](https://wordpress.org/support/users/kbat82/)
 * (@kbat82)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/stop-shortcodes-from-executing-inside-code-block/#post-18038382)
 * ah right. Probably shortcodes are processed here too. Can you check the docs?
   There’s a section on escaping. Just double the square brackets
 * [https://codex.wordpress.org/Shortcode](https://codex.wordpress.org/Shortcode)
 *  Thread Starter [Zack Pyle](https://wordpress.org/support/users/zackpyle/)
 * (@zackpyle)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/stop-shortcodes-from-executing-inside-code-block/#post-18038386)
 * Gotcha. Ok, thanks!
 *  Thread Starter [Zack Pyle](https://wordpress.org/support/users/zackpyle/)
 * (@zackpyle)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/stop-shortcodes-from-executing-inside-code-block/#post-18042885)
 * [@kbat82](https://wordpress.org/support/users/kbat82/) I just tried the double
   square bracket and it still rendered the shortcode for me?
 *  Plugin Author [Kevin Batdorf](https://wordpress.org/support/users/kbat82/)
 * (@kbat82)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/stop-shortcodes-from-executing-inside-code-block/#post-18043452)
 * It seemed to work when I tested it out using a custom shortcode. I’m assuming
   php is the language? If one gets wrapped in a span or something then it would
   break. I’m going to work on it now though and hope to have a fix released in 
   a bit. But if you can share an example (plugin name and code) I can test it out
   and confirm it’s working before I do.
 *  Thread Starter [Zack Pyle](https://wordpress.org/support/users/zackpyle/)
 * (@zackpyle)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/stop-shortcodes-from-executing-inside-code-block/#post-18043831)
 * I just tested your updated version. I created a simple just shortcode returning
   text, and it correctly escapes. But it’s not escaping [shortcodes from Beaver Builder](https://docs.wpbeaverbuilder.com/beaver-themer/field-connections/syntax/)
   
   For example `[wpbb post:title]`Thoughts?
 *  Thread Starter [Zack Pyle](https://wordpress.org/support/users/zackpyle/)
 * (@zackpyle)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/stop-shortcodes-from-executing-inside-code-block/#post-18043833)
 * I will also ask the BB team about it, because those shortcodes also don’t escape
   with the double square bracket way either. So it must be something they are doing
    -  This reply was modified 1 year, 6 months ago by [Zack Pyle](https://wordpress.org/support/users/zackpyle/).
    -  This reply was modified 1 year, 6 months ago by [Zack Pyle](https://wordpress.org/support/users/zackpyle/).
 *  Thread Starter [Zack Pyle](https://wordpress.org/support/users/zackpyle/)
 * (@zackpyle)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/stop-shortcodes-from-executing-inside-code-block/#post-18043840)
 * Fwiw, I don’t think this is something you need to solve. I think this is a Beaver
   Builder issue.
   Your solution works for “normal” shortcodes. So thank you!
 *  Thread Starter [Zack Pyle](https://wordpress.org/support/users/zackpyle/)
 * (@zackpyle)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/stop-shortcodes-from-executing-inside-code-block/#post-18043868)
 * Yeah, looks like they have their own functions for rendering shortcodes at the
   right time in the page build and they are respecting the double square brackets
   for standard shortcodes, but not their own. I have submitted a ticket for them
   to look at and see if they consider it a bug (I do)
   Either way, I have hooked
   into their filter to escape them if they have the double square bracket for now:
 * `function pre_escape_beaver_builder_shortcodes($content) {
    return preg_replace_callback('/[[(
   wpbb\s+[^]]+)]]/i', function($matches) { return '[' . $matches[1] . ']'; }, $
   content);}add_filter('fl_builder_before_render_shortcodes', 'pre_escape_beaver_builder_shortcodes',
   9);
 *  Plugin Author [Kevin Batdorf](https://wordpress.org/support/users/kbat82/)
 * (@kbat82)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/stop-shortcodes-from-executing-inside-code-block/#post-18044351)
 * Ah ok that’s why then. Well, thanks for sharing a workaround. I agree that’s 
   something they should support.
 *  Thread Starter [Zack Pyle](https://wordpress.org/support/users/zackpyle/)
 * (@zackpyle)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/stop-shortcodes-from-executing-inside-code-block/#post-18045092)
 * [@kbat82](https://wordpress.org/support/users/kbat82/) Beaver Builder support
   responded:
 * > Its been like this since around July 2015 when WP blocked the use of shortcodes
   > in HTML attributes and styles.
   > The workaround is to _escape the escape_ using triple square brackets
 *  Plugin Author [Kevin Batdorf](https://wordpress.org/support/users/kbat82/)
 * (@kbat82)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/stop-shortcodes-from-executing-inside-code-block/#post-18045114)
 * That makes sense. Are you okay with your fix? Might be a bit complicated for 
   me to add it on a _per block_ basis.
 *  Thread Starter [Zack Pyle](https://wordpress.org/support/users/zackpyle/)
 * (@zackpyle)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/stop-shortcodes-from-executing-inside-code-block/#post-18045123)
 * Yes, no need for you to do anything. I’m fine with doing the triple square bracket
   when adding a Beaver Builder shortcode. It’s not often. Thanks for checking though

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

The topic ‘Stop Shortcodes from Executing inside code block’ is closed to new replies.

 * ![](https://ps.w.org/code-block-pro/assets/icon-256x256.png?rev=2908978)
 * [Code Block Pro - Beautiful Syntax Highlighting](https://wordpress.org/plugins/code-block-pro/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-block-pro/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-block-pro/)
 * [Active Topics](https://wordpress.org/support/plugin/code-block-pro/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-block-pro/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-block-pro/reviews/)

 * 15 replies
 * 2 participants
 * Last reply from: [Zack Pyle](https://wordpress.org/support/users/zackpyle/)
 * Last activity: [1 year, 6 months ago](https://wordpress.org/support/topic/stop-shortcodes-from-executing-inside-code-block/#post-18045123)
 * Status: resolved