{"id":5532,"date":"2016-02-05T13:50:08","date_gmt":"2016-02-05T21:50:08","guid":{"rendered":"http:\/\/www.dognmonkey.com\/techs\/?p=5532"},"modified":"2017-11-14T10:43:14","modified_gmt":"2017-11-14T18:43:14","slug":"how-to-embed-shortcodes-inside-a-shortcode","status":"publish","type":"post","link":"https:\/\/www.dognmonkey.com\/techs\/how-to-embed-shortcodes-inside-a-shortcode.html","title":{"rendered":"How To Embed Shortcodes inside a Shortcode"},"content":{"rendered":"<p><link href=\"\/idogjs\/icss\/font-awesome\/css\/ifotorama.css\" rel=\"stylesheet\"><script src=\"https:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.11.3\/jquery.min.js\"><\/script><script src=\"\/idogjs\/ijs\/ifotorama.js\"><\/script><br \/>\n<em>I created a <a href=\"\/\/www.dognmonkey.com\/techs\/shortcodes-for-boostrap-collapsible.html\" target=\"_blank\" rel=\"noopener\">shortcode for Bootstrap Collapsible<\/a>, I placed a shortcode inside it like fotorama plugin and fotorama didn&#8217;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 &#8216;do_shortcode($content)&#8217; instead of just &#8216;$content&#8217; as a content inside the open and close shortcode [][\/].<\/em><\/p>\n<p style=\"text-align: center;\"><a class=\"preview\" href=\"\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/bs_shortcodes1.jpg\" rel=\"lightbox\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-5533\" src=\"\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/bs_shortcodes1-200x112.jpg\" alt=\"bs_shortcodes1\" width=\"200\" height=\"112\" \/><\/a><\/p>\n<blockquote>\n<p style=\"text-align: left;\">add_shortcode( &#8216;mybs&#8217;, &#8216;mybs_func&#8217; );<br \/>\nfunction mybs_func($atts, $content = null) {<br \/>\nextract(shortcode_atts(array(<br \/>\n&#8216;data&#8217; =&gt; &#8221;,<br \/>\n&#8216;title&#8217; =&gt;&#8221;,<br \/>\n), $atts));<br \/>\nreturn<br \/>\n&#8216;&lt;button type=&#8221;button&#8221; class=&#8221;btn btn-info&#8221; data-toggle=&#8221;collapse&#8221; data-target=&#8221;&#8216;.&#8217;#&#8217;.$atts[&#8216;data&#8217;].'&#8221;&gt;&#8217;.$atts[&#8216;title&#8217;].'&lt;\/button&gt;&#8217;.<br \/>\n&#8216;&lt;div id=&#8221;&#8216;.$atts[&#8216;data&#8217;].'&#8221; class=&#8221;collapse&#8221;&gt;&#8217;.do_shortcode($content).'&lt;\/div&gt;&#8217;<br \/>\n; }<\/p>\n<\/blockquote>\n<p style=\"text-align: center;\"><em>Examples:<\/em><\/p>\n<p>shortcode &#8220;myfotorama&#8221; top of page.<\/p>\n<p><em>This is a red button<\/em><\/p>\n<p>[title]<em>This is shortcode for collapsible bootstrap<\/em> [\/title][body]<\/p>\n<p><em>This is fotorama gallery inside the collapsible bootstrap body<\/em><\/p>\n<p><em>shortcode &#8220;gallery ids=&#8221;6476,6475,6473,6474,6471&#8243; allowfullscreen=yes&#8221;<\/em><\/p>\n<div class='fotorama--wp' data-ids='6476,6475,6473,6474,6471'data-allowfullcscreen='yes'data-link='file'data-itemtag='dl'data-icontag='dt'data-captiontag='dd'data-columns='0'data-size='large'data-width='800'data-auto='false'data-max-width='100%'data-ratio='1.7777777777778'><div id='gallery-1' class='gallery galleryid-5532 gallery-columns-0 gallery-size-thumbnail'><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_13.jpg' data-full='https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_13.jpg'><img loading=\"lazy\" decoding=\"async\" width=\"200\" height=\"112\" src=\"https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_13-200x112.jpg\" class=\"w3-image attachment-thumbnail size-thumbnail\" alt=\"\" aria-describedby=\"gallery-1-6476\" srcset=\"https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_13-200x112.jpg 200w, https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_13-300x169.jpg 300w, https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_13.jpg 800w\" sizes=\"auto, (max-width: 200px) 100vw, 200px\" \/><\/a>\n\t\t\t<\/dt>\n\t\t\t\t<dd class='wp-caption-text gallery-caption' id='gallery-1-6476'>\n\t\t\t\tImage1\n\t\t\t\t<\/dd><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_12.jpg' data-full='https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_12.jpg'><img loading=\"lazy\" decoding=\"async\" width=\"200\" height=\"112\" src=\"https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_12-200x112.jpg\" class=\"w3-image attachment-thumbnail size-thumbnail\" alt=\"\" aria-describedby=\"gallery-1-6475\" srcset=\"https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_12-200x112.jpg 200w, https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_12-300x169.jpg 300w, https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_12.jpg 800w\" sizes=\"auto, (max-width: 200px) 100vw, 200px\" \/><\/a>\n\t\t\t<\/dt>\n\t\t\t\t<dd class='wp-caption-text gallery-caption' id='gallery-1-6475'>\n\t\t\t\tImage2\n\t\t\t\t<\/dd><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_10.jpg' data-full='https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_10.jpg'><img loading=\"lazy\" decoding=\"async\" width=\"200\" height=\"112\" src=\"https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_10-200x112.jpg\" class=\"w3-image attachment-thumbnail size-thumbnail\" alt=\"\" aria-describedby=\"gallery-1-6473\" srcset=\"https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_10-200x112.jpg 200w, https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_10-300x169.jpg 300w, https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_10.jpg 800w\" sizes=\"auto, (max-width: 200px) 100vw, 200px\" \/><\/a>\n\t\t\t<\/dt>\n\t\t\t\t<dd class='wp-caption-text gallery-caption' id='gallery-1-6473'>\n\t\t\t\tImage3\n\t\t\t\t<\/dd><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_11.jpg' data-full='https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_11.jpg'><img loading=\"lazy\" decoding=\"async\" width=\"200\" height=\"112\" src=\"https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_11-200x112.jpg\" class=\"w3-image attachment-thumbnail size-thumbnail\" alt=\"\" aria-describedby=\"gallery-1-6474\" srcset=\"https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_11-200x112.jpg 200w, https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_11-300x169.jpg 300w, https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_11.jpg 800w\" sizes=\"auto, (max-width: 200px) 100vw, 200px\" \/><\/a>\n\t\t\t<\/dt>\n\t\t\t\t<dd class='wp-caption-text gallery-caption' id='gallery-1-6474'>\n\t\t\t\tImage4\n\t\t\t\t<\/dd><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_08.jpg' data-full='https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_08.jpg'><img loading=\"lazy\" decoding=\"async\" width=\"200\" height=\"112\" src=\"https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_08-200x112.jpg\" class=\"w3-image attachment-thumbnail size-thumbnail\" alt=\"\" aria-describedby=\"gallery-1-6471\" srcset=\"https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_08-200x112.jpg 200w, https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_08-300x169.jpg 300w, https:\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/z_TS20_08.jpg 800w\" sizes=\"auto, (max-width: 200px) 100vw, 200px\" \/><\/a>\n\t\t\t<\/dt>\n\t\t\t\t<dd class='wp-caption-text gallery-caption' id='gallery-1-6471'>\n\t\t\t\tImage5\n\t\t\t\t<\/dd><\/dl>\n\t\t<\/div>\n<\/div>\n<p>[\/body]<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: left;\"><ul class=\"lcp_catlist\" id=\"lcp_instance_0\"><\/ul><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I created a shortcode for Bootstrap Collapsible, I placed a shortcode inside it like fotorama plugin and fotorama didn&#8217;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 &#8216;do_shortcode($content)&#8217; instead of just &#8216;$content&#8217; as a content inside the <a href=\"https:\/\/www.dognmonkey.com\/techs\/how-to-embed-shortcodes-inside-a-shortcode.html\" class=\"more-link\">&#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[807,20],"tags":[799,920,1107,1108,809],"class_list":["post-5532","post","type-post","status-publish","format-standard","hentry","category-scripts","category-wordpress","tag-bootstrap-collapsible","tag-fotorama","tag-fotorama-gallery","tag-fotorama-shortcode","tag-shortcodes-inside-shortcode"],"views":161,"_links":{"self":[{"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/posts\/5532","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/comments?post=5532"}],"version-history":[{"count":3,"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/posts\/5532\/revisions"}],"predecessor-version":[{"id":6595,"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/posts\/5532\/revisions\/6595"}],"wp:attachment":[{"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/media?parent=5532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/categories?post=5532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dognmonkey.com\/techs\/wp-json\/wp\/v2\/tags?post=5532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}