We all love shortcodes.
Bits of reusable content that can be easily inserted into a post or page via an easy-to-remember tag. Who doesn’t love ‘em?
For those who don’t know, shortcodes look something like this:
[this-is-a-shortcode foo="bar"]. When visitors see the post on your blog, the shortcode is magically transformed into whatever content they are 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 code, without it actually executing. You can escape shortcodes by adding an extra set of square brackets around it – like