Created
June 5, 2015 19:44
-
-
Save AlexanderOMara/aa28679c2182055e7539 to your computer and use it in GitHub Desktop.
do_shortcode inside shortcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Parses shortcodes inside shortcodes by passing the content into do_shortcode. | |
[testouter][testinner][/testinner][/testouter] | |
*/ | |
function shortcode_test_outer( $atts, $content = null ) { | |
?><p>shortcode-outer-start</p><?php | |
do_shortcode( $content ); | |
?><p>shortcode-outer-end</p><?php | |
} | |
add_shortcode( 'testouter', 'shortcode_test_outer' ); | |
function shortcode_test_inner( $atts, $content = null ) { | |
?><p>shortcode-inner-start</p><?php | |
do_shortcode( $content ); | |
?><p>shortcode-inner-end</p><?php | |
} | |
add_shortcode( 'testinner', 'shortcode_test_inner' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Parses a hardcoded shortcode inside another shortcode by passing the shortcode string to do_shortcode. | |
[testouter][/testouter] | |
*/ | |
function shortcode_test_outer( $atts, $content = null ) { | |
?><p>shortcode-outer-start</p><?php | |
do_shortcode( '[testinner][/testinner]' ); | |
?><p>shortcode-outer-end</p><?php | |
} | |
add_shortcode( 'testouter', 'shortcode_test_outer' ); | |
function shortcode_test_inner( $atts, $content = null ) { | |
?><p>shortcode-inner-start</p><?php | |
?><p>shortcode-inner-end</p><?php | |
} | |
add_shortcode( 'testinner', 'shortcode_test_inner' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment