Nestable Shortcodes

This Article Applies to

First_matryoshka_museum_doll_openWhen working with conditional shortcodes it’s often useful to have a series of tests, one after another, where each test determines if the user is qualified to continue to the next test.

Due to a limitation in WordPress’s design, the built-in shortcode system is very fast but it does not know how to count levels of nesting, so it cannot match each opening tag with its correct closing tag. In order to cleanly support this feature while not sacrificing performance, we provide the ability to nest shortcodes by giving each nested group of shortcodes a unique name by adding a number to the end. You can think of this like a Russian Matryoshka doll.

Some basic rules of nesting shortcodes:

Not all shortcodes can be nested. Only conditional shortcodes are ever made to be nested. There is no reason to nest a non-conditional shortcode.

Not all shortcodes can be nested the same number of times. A few simple shortcodes which perform very simple test can only be nested a few times since their tests are very limited.

There is a limited number of times that any given shortcode can be nested.

To nest a shortcode simply add a number to the end of the shortcode name. Similarly for [else_ and closing shortcode markup, you would add the matching number as well.

Some examples:

[memb_is_logged_in]
	[memb_is_logged_in1]
		[memb_is_logged_in2]
		[else_memb_is_logged_in2]
		[/memb_is_logged_in2]
	[else_memb_is_logged_in1]
	[/memb_is_logged_in1]
[else_memb_is_logged_in]
[/memb_is_logged_in1]
9 ways to add more value to your membership site

Table of Contents

This Article Applies to

Related Posts

Auto Excerpt Length

This feature allows you to set the number of words for Memberium to use from the page/post’s content to to automatically create an excerpt or teaser content.

Read More »

Does ActiveCampaign have a free plan?

As an entrepreneur, you’re always looking for ways to reduce costs and optimize your business. When it comes to marketing automation, ActiveCampaign is a great option with a variety of pricing plans to fit your needs. But does ActiveCampaign have a free plan? Keep reading to find out more.

Read More »

Sync Meta Updates

Sync Meta Updates is designed to enable other plugins/code to access ActiveCampaign fields as if they were normal WordPress User Meta Fields.

Read More »

Ready to See How You Can Automate Your Course or Membership With Memberium for ActiveCampaign?

Watch this quick demo video to see how Memberium works. Discover how thousands of successful business owners use Memberium to sell their membership programs and how you can too! If you’re ready to get started, you can check out our plans and pricing here…