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:

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

The shortcode [product] won’t be executed.

Love and peace.

My excuses for my bad english but it's the only way I have to communicate with you. Would you suggest a correction? Leave a comment, thank you!
Categories: WordPress

0 Comments

Leave a Reply