WordPress Tricks: Allowing the use of shortcodes within custom shortcodes

I was recently working on a site where I needed to add custom shortcodes and also allow the use of shortcodes within my custom shortcodes and here is how I did it.

I started by adding the standard code for creating custom shortcodes to my functions.php file:

function my_custom_shortcode( $atts, $content = null ) {
    return '<div class="customText">'.$content .'</div>';
}
add_shortcode("customText", "my_custom_shortcode");

And then wrapped $content in the do_shortcode() function, like this:

function my_custom_shortcode( $atts, $content = null ) {
    return '<div class="customText">'. do_shortcode($content) .'</div>';
}
add_shortcode("customText", "my_custom_shortcode");

Now I am able to use standard WordPress shortcodes within my custom shortcode, like so:

[customText] This is my custom text with a shortcode.[button value="Read More..."] [/customText]