Title: Shortcode inside a shortcode inside a shortcode
Last modified: April 29, 2020

---

# Shortcode inside a shortcode inside a shortcode

 *  [juliushg](https://wordpress.org/support/users/juliushg/)
 * (@juliushg)
 * [6 years ago](https://wordpress.org/support/topic/shortcode-inside-a-shortcode-inside-a-shortcode/)
 * I checked but I couldn’t find a similar topic. I’m using Formidable Forms Pro
   plugin and I noticed I can’t make Private to work when a shortcode is inside 
   a shortcode, executing it from that second level.
 * In Formidable Form Pro, there is a display shortcode that renders a View from
   a form data. Then I can use Private with no problem inside this View called by
   the shortcode:
 * This:
    [display-frm-data id=x param=y]
 * Display a View with fields and I can put a [private role=administrator]content[/
   private] there.
 * But if this view contains another shortcode to display a nested view, this is:
 * [display-frm-data id=view1 filter=limited] <- first FF shortcode
    renders:
 * View1
    [display-frm-data id=view2 param=pass_field]
 * I can’t make to work the Private content shortcode in that nested second view.
   It shows the syntax of the shortcode itself:
 * [private role=administrator]content[/private] <- it shows all this.
 * Is there something I’m missing or it can’t work in the second nested view?

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Aldo Latino](https://wordpress.org/support/users/aldolat/)
 * (@aldolat)
 * [6 years ago](https://wordpress.org/support/topic/shortcode-inside-a-shortcode-inside-a-shortcode/#post-12751502)
 * Hello [@juliushg](https://wordpress.org/support/users/juliushg/),
    according 
   to the [WordPress documentation](https://codex.wordpress.org/Shortcode_API#Nested_Shortcodes),
   you can’t nest a shortcode inside another shortcode when they have the same name:
 * > The parser will fail if a shortcode macro is used to enclose another macro 
   > of the same name
 * This means that you can do this:
 *     ```
       [shortcode-a]
          [shortcode-b]
             [shortcode-c]
          [/shortcode-b]
       [/shortcode-a]
       ```
   
 * but you can’t do this:
 *     ```
       [shortcode-a]
          [shortcode-a]
             [shortcode-a]
          [/shortcode-a]
       [/shortcode-a]
       ```
   
 * In your case, using these shortcodes:
 *     ```
       [display-frm-data {options}]
          [private role=administrator]content[/private]
       [/display-frm-data]
       ```
   
 * should work, but the following form won’t work:
 *     ```
       [display-frm-data {options}]
          [display-frm-data {options}]
             [private role=administrator]content[/private]
          [/display-frm-data]
       [/display-frm-data]
       ```
   
 * because there are two nested shortcodes with the same name `display-frm-data`.
 * Let me know, please.
 *  Thread Starter [juliushg](https://wordpress.org/support/users/juliushg/)
 * (@juliushg)
 * [6 years ago](https://wordpress.org/support/topic/shortcode-inside-a-shortcode-inside-a-shortcode/#post-12755238)
 * Well, actually I can. Maybe I took for granted that you would know that Formidable
   Forms works that way. I invoke the second view with a shortcode inside the first,
   just like that, and it works.
 *     ```
       [display-frm-data {options}]
          [display-frm-data {options}]
             content here
          [/display-frm-data]
       [/display-frm-data]
       ```
   
 * That is useful and necessary for the plugin to work properly, because I’m setting
   a category in the first shortcode and passing a parameter to the second to show
   entries in that category (a field).
 * What won’t work is the private shortcode inside the second nested display.
 * This is:
 *     ```
       [display-frm-data {options}]
          Other content here
          [private role=administrator]This works fine, hidden[/private]
       [/display-frm-data]
       ```
   
 * But…
 *     ```
       [display-frm-data {options}]
          [display-frm-data {options}]
             Other content here, works fine
             [private role=administrator]This is not hidden[/private]
          [/display-frm-data]
       [/display-frm-data]
       ```
   
 * Instead of hiding the content, it shows all the shortcode syntax there:
 * `[private role=administrator]Does not hide[/private]` This is shown as is.
 * Thanks for your response. Your plugin is great. I understand that I maybe should
   contact the FF developers, unless the solution is in yours. Can you think what
   is happening?
 *  Plugin Author [Aldo Latino](https://wordpress.org/support/users/aldolat/)
 * (@aldolat)
 * [6 years ago](https://wordpress.org/support/topic/shortcode-inside-a-shortcode-inside-a-shortcode/#post-12760517)
 * At this point I have no explanation why `[display-frm-data]` shortcode works 
   even with two nested shortcodes with the same name.
 * My advice is to ask the developer of this plugin and ask why you can’t nest Private
   Content shortcode in the third level.
 * But, before asking, try this: add a third level of the same shortcode. It works
   up to the second level. Does it work with a third one having the same name? I
   mean:
 *     ```
       [display-frm-data {options}]
          [display-frm-data {options}]
                [display-frm-data {options}] <--- Does it work?
                [/display-frm-data]
          [/display-frm-data]
       [/display-frm-data]
       ```
   
 * Let me know.
 *  Thread Starter [juliushg](https://wordpress.org/support/users/juliushg/)
 * (@juliushg)
 * [6 years ago](https://wordpress.org/support/topic/shortcode-inside-a-shortcode-inside-a-shortcode/#post-12768030)
 * Yes, it works. The 3rd level nesting can be done.
 * But I had a little surprise:
    I injected the Private code in the three levels
   of the nested views, and now **it only does not work in the last level**. But
   in level one and two works perfectly.
 * Anyway, the two level nesting is documented in the FF docs, here: [https://formidableforms.com/knowledgebase/advanced-view-concepts/#kb-set-up-a-nested-view](https://formidableforms.com/knowledgebase/advanced-view-concepts/#kb-set-up-a-nested-view)
 * So I experimented a little and added a third level, and it worked, but now that
   happened. Not a big deal, but I would like to understand what is causing this
   issue.
 * Tell me if I can privately send you a link to the page of my site where it shows
   the result, in your email perhaps? Or when may I contact you, just to explore
   this.
 *  Plugin Author [Aldo Latino](https://wordpress.org/support/users/aldolat/)
 * (@aldolat)
 * [6 years ago](https://wordpress.org/support/topic/shortcode-inside-a-shortcode-inside-a-shortcode/#post-12768287)
 * Julius,
 * > But I had a little surprise:
   >  I injected the Private code in the three levels
   > of the nested views, and now it only does not work in the last level. But in
   > level one and two works perfectly.
 * My advice is to contact the developer of Formidable Forms and ask him if it’s
   possible to nest the shortcode of another plugin inside multiple FF nested shortcodes.
   Tell him the various tests you made, especially when you nest two and three levels.
 * Then, let me know.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Shortcode inside a shortcode inside a shortcode’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/private-content_924d8c.svg)
 * [Private Content](https://wordpress.org/plugins/private-content/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/private-content/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/private-content/)
 * [Active Topics](https://wordpress.org/support/plugin/private-content/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/private-content/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/private-content/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Aldo Latino](https://wordpress.org/support/users/aldolat/)
 * Last activity: [6 years ago](https://wordpress.org/support/topic/shortcode-inside-a-shortcode-inside-a-shortcode/#post-12768287)
 * Status: not resolved