How to Escape Shortcodes in a WordPress post

WordPress has a feature called shortcodes, which allow you to embed dynamically generated content, often from plugins, into your posts by wrapping the shortcode in square brackets [ and ]. For example, to embed a MailPress signup form, you go:


This works great, unless you're writing about WordPress plugins, and want to describe the shortcode rather than have it activate. In this case, you need to escape the shortcode by doubling the square brackets around it, like this:


(If you're really paying attention, you'll realize that I had triple brackets around that last example while editing this article.)

Liked this post? Subscribe to get more like it via email.

About Graham

I'm the creator of
This entry was posted in Content and tagged . Bookmark the permalink.

3 Responses to How to Escape Shortcodes in a WordPress post

  1. Yeah, I realized that when it gave me a syntax error in the very last line. Almost finished and then I still managed to f--- it up. 🙁

  2. This escaping mechanism doesn't always work. I.e. with opening/closing and nested shortcodes you need a slightly different syntax. And when you only want to escape an opening shortcode, it can break your page if you just escape it by doubling it.

    I tried to list some of the alternatives in this blogpost on escaping shortcodes.

    • Hiinoush says:

      First, my thanks to the aouthr of this column, as it cleared a lot of issues I didn't know about. No matter how I have set the MailPress, the MP has been always sending emails over the limit allowed by the provider. Second, a little clarification that will save newbies, like me, a lot of time: The sample path MailPress gives you when you select "Submit batch with: Other:" is not a complete path, unless it starts with /usr/bin/php -f and ends with cron.php It was my case and it took me forever to figure out I had to insert it on the path manually. One more thing, I have to emphasize. You have to get email cron message with a simple "1", anything else in the message is a sign of cron not set up properly. Jan Kasal recently posted..Petition The Malverne Board of Education

Comments are closed.