Tag: shortcodes @en

Escape shortcodes

If you write your own WordPress plugin, you usually set up a new page to document the plugin and how to work with this plugin. If you are using shortcodes, you might run into problems, since you can’t simply write your shortcode into the editor without executing it. I always used an extra script, which I was placing into the functions.php: “Stop shortcode”. This script simply delivered me a shortcode with a single purpose: Not to execute the shortcodes, which are wrapped into it. But today, while reading the regular expressions of the shortcodes (which can be found in wp-includes/shortcodes.php) I found out, you are able to escape shortcodes!

Usually, a shortcode starts with an opening bracket (this sign: [ ) and it ends with a closing bracket (this sign: ] ). But if you use instead [[ to open your shortcode, the shortcode itself won’t be rendered. So [[gallery]] will not render the gallery but output [gallery].

If you want to escape a shortcode with content, you simply write:


Photo Credit: Execute, CC 2.0