How To Embed Shortcodes inside a Shortcode

I created a shortcode for Bootstrap Collapsible, I placed a shortcode inside it like fotorama plugin and fotorama didn’t work. I Googled the problem and I found the fix on WP website. In order for a shortcode to output another shortcode, you need to use ‘do_shortcode($content)’ instead of just ‘$content’ as a content inside the open and close shortcode [][/].


add_shortcode( ‘mybs’, ‘mybs_func’ );
function mybs_func($atts, $content = null) {
‘data’ => ”,
‘title’ =>”,
), $atts));
‘<button type=”button” class=”btn btn-info” data-toggle=”collapse” data-target=”‘.’#’.$atts[‘data’].'”>’.$atts[‘title’].'</button>’.
‘<div id=”‘.$atts[‘data’].'” class=”collapse”>’.do_shortcode($content).'</div>’
; }


shortcode “myfotorama” top of page.

This is a red button

[title]This is shortcode for collapsible bootstrap [/title][body]

This is fotorama gallery inside the collapsible bootstrap body

shortcode “gallery ids=”6476,6475,6473,6474,6471″ allowfullscreen=yes”



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.