How To Disable Shortcodes on Part of a Post

It may happen you need to disable shotcodes in a post or part of a post, because you’re writing documentation and you need to write shortcode examples and be sure they won’t be executed.

Ok, I know, you can use the double square brackets but there were times went I went into trouble with shortcodes.

But it’s pretty easy to remedy. You can create a shortcode which displays its content without executing the inner shortcodes. 3 lines, no more.

add_shortcode('disable_shortcodes', function ($atts, $content) {
return $content;

The code above declares a shortcode to disable the execution of other shortcodes. So if in a post you write:

Content with shortcodes, for example [product id="3"]

The shortcode [product] won’t be executed.

Love and peace.

Leave a Reply