0

How would you do a shortcode wrapper that can differentiate between different nested shortcodes.

[teaching_tool_wrapper param1="true" param2="false"]
    [chord param1="something"]
    [scale param1="something-else"]
[/teaching_tool_wrapper]

I have it working fine with just the [chord] shortcode, however i'm not sure how to get the wrapper differentiating between the two different types of nested shortcodes.

0

Can be useful do_shortcode function?

http://codex.wordpress.org/Function_Reference/do_shortcode

0

I've figured out a solution. do_shortcode will do all the shortcode contents in the wrapper, however I wanted the nested shotcodes processed in different places.

<?php 
    // make sure only the [chord] shortcodes are inserted here.
    $custom_chords = rtrim($custom_chords, "]");
    $custom_chords_array = explode(']', strip_tags($custom_chords));
    foreach($custom_chords_array as $custom_chord){
        if(strpos($custom_chord, '[chord') != false){
            echo do_shortcode($custom_chord .']');
        }
    }
?>

Seems to work!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.