{"id":33820,"date":"2019-03-01T10:00:12","date_gmt":"2019-03-01T10:00:12","guid":{"rendered":"http:\/\/getshortcodes.com\/?post_type=docs&#038;p=33820"},"modified":"2020-01-27T11:57:43","modified_gmt":"2020-01-27T11:57:43","slug":"nested-shortcodes-shortcodes-in-attributes","status":"publish","type":"docs","link":"https:\/\/getshortcodes.com\/docs\/nested-shortcodes-shortcodes-in-attributes\/","title":{"rendered":"Nested shortcodes, shortcodes in attributes"},"content":{"rendered":"<p class=\"h2\">Table of contents<\/p>\n\n<ol><li><a href=\"#introduction\">Introduction<\/a><\/li><li><a href=\"#nested-shortcodes-with-the-same-tag-names\">Nested shortcodes with the same tag names<\/a><\/li><li><a href=\"#use-of-shortcodes-inside-the-attributes-of-other-shortcodes\">Use of shortcodes inside the attributes of other shortcodes<\/a><\/li><\/ol><\/li><\/ol>\n\n\n<h2 class=\"wp-block-heading\" id=\"introduction\">Introduction<\/h2>\n\n\n\n<p class=\"has-text-color has-background has-black-color has-yellow-background-color\">This article is rather a bad example and was published here just because many users wonder how to create nested shortcodes. I do not recommend to use approaches described in this article, unless it is really necessary. Besides, I would like to mention that the same behaviour is not guaranteed in all shortcodes.<\/p>\n\n\n\n<p>Some SU shortcodes can be nested, like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[shortcode]\n  Hello, [another_shortcode]\n[\/shortcode]<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"nested-shortcodes-with-the-same-tag-names\">Nested shortcodes with the same tag names<\/h2>\n\n\n\n<p>Shortcodes with the same names cannot be nested into each other. For example, the structure presented below will not work:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#000000;border-radius:3px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#333333;color:#FFFFFF;border-top-left-radius:1px;border-top-right-radius:1px\">This is box title<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:1px;border-bottom-right-radius:1px\">\n   <div class=\"su-box su-box-style-default\" id=\"\" style=\"border-color:#000000;border-radius:3px;max-width:none\"><div class=\"su-box-title\" style=\"background-color:#333333;color:#FFFFFF;border-top-left-radius:1px;border-top-right-radius:1px\">This is box title<\/div><div class=\"su-box-content su-u-clearfix su-u-trim\" style=\"border-bottom-left-radius:1px;border-bottom-right-radius:1px\"><\/div><\/div> This will NOT work <\/div><\/div>\n[\/su_box]<\/pre>\n\n\n\n<p>If you want to nest shortcodes with the same names anyway, then you should use underscore character &#8220;_&#8221; before the name of a nested shortcode, e.g.:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><div class=\"su-spoiler su-spoiler-style-default su-spoiler-icon-plus su-spoiler-closed\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span>Spoiler title<\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\">\n  <div class=\"su-spoiler su-spoiler-style-default su-spoiler-icon-plus su-spoiler-closed\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span>Spoiler title<\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\"> Content <\/div><\/div>\n  <div class=\"su-spoiler su-spoiler-style-default su-spoiler-icon-plus su-spoiler-closed\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span>Spoiler title<\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\"> Content <\/div><\/div>\n<\/div><\/div><\/pre>\n\n\n\n<p>In case if you need to nest shortcodes with the same name more than one level deep, you can enable the deprecated nesting mode. This implementation was used in the plugin earlier, but now it is disabled by default due to complexity. Navigate to <em>Dashboard \u2013 Shortcodes \u2013 Settings \u2013 Advanced Settings<\/em>, tick the <em>Nested shortcodes alternative mode<\/em> checkbox, save changes and use the following syntax:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><div class=\"su-spoiler su-spoiler-style-default su-spoiler-icon-plus su-spoiler-closed\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span>Spoiler title<\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\">\n<div class=\"su-spoiler su-spoiler-style-default su-spoiler-icon-plus su-spoiler-closed\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span>Spoiler title<\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\">\n[__su_spoiler]\n[___su_spoiler]\nHidden content\n[___\/su_spoiler]\n[__\/su_spoiler]\n<\/div><\/div>\n<\/div><\/div><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"use-of-shortcodes-inside-the-attributes-of-other-shortcodes\">Use of shortcodes inside the attributes of other shortcodes<\/h2>\n\n\n\n<p>Some plugin shortcodes allow using other shortcodes in their attributes.<\/p>\n\n\n\n<p>To do that, in nested shortcodes replace square brackets (<code>[<\/code>, <code>]<\/code>) with curly brackets (<code>{<\/code>, <code>}<\/code>) and double quotes (<code>\"<\/code>) with single quotes (<code>'<\/code>). Example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><div class=\"su-spoiler su-spoiler-style-default su-spoiler-icon-plus su-spoiler-closed\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span>[user field='display_name']<\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\"> Content <\/div><\/div><\/pre>\n","protected":false},"featured_media":0,"template":"","docs_category":[20],"class_list":["post-33820","docs","type-docs","status-publish","hentry","docs_category-getting-started"],"_links":{"self":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/docs\/33820","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/types\/docs"}],"wp:attachment":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/media?parent=33820"}],"wp:term":[{"taxonomy":"docs_category","embeddable":true,"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/docs_category?post=33820"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}