It may happen that you need to disable shortcodes 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 that 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.

Similar Posts

Leave a Reply