• Home
  • Features
    • Membership Software
    • Member Directory
    • Event Calendar & Registration
    • Member Billing & Online Payments
    • Donations, Shopping Carts & Forms
    • Job Board
    • Announcement Board
    • Classified Ads
    • Members Only Website
    • Website Integration
      • WordPress
      • Squarespace
      • Weebly
      • Without Code
      • Duda
      • Wix
      • HTML5
    • Integrations
    • International
  • Sign Up
    • Pricing & Sign Up
  • Customers
    • Customer Sign In
    • Getting Started
      • MembershipWorks Hosted Website
      • WordPress Plugin
      • Squarespace
      • Weebly
      • Without Code
      • Wix
      • HTML5
    • Customer Websites
  • Developers
    • Find a Developer
    • Create a Developer Listing
    • Manage Developer Listing
  • Demo
    • WordPress Demo
    • Squarespace Demo
    • Weebly Demo
    • Without Code Demo
    • Duda Demo
    • Wix Demo
    • Video Demo of Admin
    • Schedule a Personal Demo
  • About
    • Contact Us
    • Cancel/Suspend Account
    • Schedule a Personal Demo
    • Schedule a Personal Training Session
    • Our Blogs
      • Guides
      • Best Practices
      • Secret Confessions of an ED
      • WordPress with the Light On
    • New Features
    • Careers
    • System Status
Schedule Demo

Discover our membership software with a one-on-one personalized demo:

Schedule a Demo
CMS Integrations

Integrate with WordPress, SquareSpace, Weebly and more.

Learn More!
MembershipWorkslogo

Escaping Shortcodes in WordPress

Posted on Apr 2, 2013 by Aikmeng KuahOct 3, 2019

Documenting shortcodes is a common task for WordPress plugin developers.  You can either use the html entities “[” for “[“and ] for “]”, or use double brackets “[[” and “]]” to escape the shortcode:

[shortcode]
[[shortcode]]

Using the html entities would require going into the Text (HTML) mode of the editor, so using the double bracket method would be easier. That is until you attempt to put actions into your shortcodes…

My shortcode function would enque a script when it is called. Today, I noticed some blog pages on the site loading the script, even when the shortcode should not be running.  That happened not just on the blog page itself, but on the post list as well. Apparently with the double bracket method, the PHP function for the shortcode is still called, but the output returned from the function is ignored.

I would not expect this behavior if the shortcode is supposed to be escaped… perhaps this is a bug that will be fixed in future versions of WordPress. For me, I’m documenting my shortcodes using html entities from now on, instead of double brackets.  You’ve been warned!

GoToOlder PostNewer PostAll PostsWordPress with the Light On

About Aikmeng Kuah

I'm co-founder and CTO of MembershipWorks. I've been writing code since the Apple II, in a variety of languages including x86 assembly, 68000 assembly, Pascal, Prolog, dBase, C, LISP, SQL, PHP and Javascript. I work on the full stack, from the web site design, front-end web app, back-end servers, database and API. I am a graduate of Carnegie Mellon University (BS) and University of Texas at Austin (PhD).View all posts by Aikmeng Kuah

Comments are closed.

  • Home
  • Features
  • Sign Up
  • Customer Sign-In
  • Terms of Service / Privacy
  • Developers
  • Contact