Shortcodes are a useful tool in WordPress, when used correctly. They are designed to be used in post content and look something like this: [this-is-a-shortcode foo="bar"]
. When visitors see the post rendered on the site, the shortcode is transformed into whatever content it is set to hold.
There is a small problem with shortcodes, and that is when trying to publish a post, such as this one, and you want to show the reader how to insert shortcodes, such as a shortcode built-in to WordPress, like [gallery]
, or one created by a plugin, like [column]
, how do you display the actual shortcode in your post, without it being replaced with its predefined contents?
The secret is called escaping. That means that you want to show the source of some code, without actually executing it. You can escape shortcodes by adding an extra set of square brackets around it – like [[gallery]]
, or [[column]]
.