How to Use Memberium Custom Shortcodes

David Bullock — 

Soldatenmesser_08-2Custom Shortcodes are one of the advanced features in Memberium. Like regular shortcodes, Custom Shortcodes are powerful little commands that you can use in your pages to make your site do different things.

They provide a convenient way for non-programmers to create advanced functionality without having to dive into PHP. All Memberium’s custom shortcodes are in all lowercase, and start with “membc_”.

You can access your custom shortcodes by using the menu on the left side of the WordPress admin dashboard.

Custom Shortcodes vs. Partials

Custom shortcodes differ from partials in two important respects. Custom shortcodes have unique shortcode names like other shortcodes, whereas partials are inserted into the page by another shortcode. Custom shortcodes can also process custom attributes, which allow you to make custom shortcodes behave in a dynamic way.

Using Attributes With Custom Shortcodes

Custom shortcode attributes are where the real power is. These attributes follow all the same rules as regular Shortcode attributes. Attributes allow each single shortcode to do many different things.

Pro Tip
Keep your attribute names descriptive but as short as possible. They must not include spaces, and all lowercase letters are best.

Assigning Attributes in your Shortcode
The names of shortcode attributes are always all in lowercase. IF the value of your attribute has spaces in it, then you’ll need to enclose it in quotes so that WordPress knows where your value starts and finishes. You can use either single quotes, or double quotes. If your custom shortcode is placed inside of quotes, it is important that you use different quotes inside your shortcode.

Example:

Pro Tip
If you need to use a single or double quote in your attribute value, be sure to escape it like this: "

Referencing Attributes inside the Shortcode
Once you’ve assigned a value to an attribute in your custom shortcode, you’ll want to reference that value inside your custom shortcode content. Attributes are referenced by the name you assign to them when you place the custom shortcode on the page.

In the example custom shortcode above, you would reference the values of the “x” and “a” attributes above like this:

Inside your custom shortcode, you can use any combination of WordPress or Memberium shortcodes to create your output. You can even use custom shortcodes inside other custom shortcodes. Custom shortcode inception.

Pro Tip
Don’t create loops of custom shortcodes.