Developer Challenge: Nested Shortcode of Same Instance
-
Hi all, I’m sure many of you are aware of the infamous restriction in wordpress shortcodes where nesting a shortcode of the same name is unsupported. This is becoming increasingly undesirable as theme developers include “front end” designer-like tools such as Visual Composer.
I’ve seen countless threads where developers would love to give their clients more control over the design structure of their content directly within a page/post without having to write html that *could* and *often* becomes molested by the core’s filtering, i.e. extra p tags, removal of classes and empty elements such a span tags used for icons, etc. For example, I personally would love to give my clients the ability to build semantic html directly within the editor using a visual tool taking advantage of a form driven approach.
So I have a challenge. The thought occurred to me, there must be a way around this WITHOUT hacking the core. However, my personal strengths are css and js, not so much php even though I have written my fair share of themes and plugins.
One thought, is to somehow extend the core “do_shortcode” function. This thread suggest hacking the core however, I really don;t know if its possible to “extend” this from a plugin or theme functions.php since its not a class. https://wordpress.stackexchange.com/questions/70290/does-wordpress-support-a-shortcode-calling-itself-from-within-a-shortcode-call
Another thought but not sure if this is possible either is to use a filter against the “name” of the shortcode along with a unique trailing id so a shortcode with the same name is never actually nested within itself. For example, if I wrote a shortcode such as [section][/section], and somehow we tell wordpress that any [section_*][/section_*] (where _* is any unique id such as a timestamp) renders using the defined [section] shortcode. Is this possible?
If you think so, let the challenge begin and most importantly, have fun =)
- The topic ‘Developer Challenge: Nested Shortcode of Same Instance’ is closed to new replies.