WooCommerce: How to Write Shortcodes Without Outputting Content?

When I write tutorials like WooCommerce Separate Login & Registration Pages I often need to “write” on the screen the actual shortcode – but I don’t want the shortcode to output content!

For example, if I write [woocommerce_my_account] it’s guaranteed you won’t see “[woocommerce_my_account]“… you will see Business Bloomer’s My Account page content instead!

So there is a great workaround for those of you who write tutorials, snippets and WordPress articles and need to print the actual shortcode on the screen, without making it “process” its content and outputting it.

Enjoy!

Use double square-brackets instead of single ones

I searched online and actually found a very neat way to “write” shortcodes, without messing up with the output.

The great news is that the reader won’t see them: the output will have single square-brackets, but the shortcode won’t output the content.

If you want to “print” a shortcode on the screen (and this is valid for ANY EXISTING WordPress and third party plugin & theme shortcodes), use:


[[my_shortcode]]

Once you write that in the WordPress content editor, you will see this on the screen:

[my_shortcode]

If the shortcode does not exist, the screen will feature double quotes, as there is nothing to output:

[[my_shortcode]]

Rodolfo Melogli

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as a WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

Questions? Feedback? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between: [php]code_here[/php]. Failure to complying with this (as well as going off topic) will result in comment deletion. You should expect a reply in about a week - this is a popular blog but I need to get paid work done first. Please consider joining #BloomerArmada to ask me 1-to-1 WooCommerce questions. Thank you :)

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.