Title: Nesting the shortcode
Last modified: February 26, 2020

---

# Nesting the shortcode

 *  Resolved [songiuno](https://wordpress.org/support/users/songiuno/)
 * (@songiuno)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/nesting-the-shortcode/)
 * Is it possible, or is it already functional and I’m doing it wrong, to nest the
   shortcode to further restrict view within an existing restriction? For instance,
   if I have a restriction to family and friends, and then within that section I
   want to further restrict a paragraph to only family, can I do that?
 * example:
    [private role=”custom” custom_role=”family,friends”] Only family and
   friends can read this. [private role=”custom” custom_role=”family”] Only family
   can read this, friends are excluded. [/private] Family and friends can read the
   rest of this page. [/private]
 * Not a big deal if this is not a function. I was just wondering so I know what
   restriction strategeies can be used.

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

 *  Plugin Author [Aldo Latino](https://wordpress.org/support/users/aldolat/)
 * (@aldolat)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/nesting-the-shortcode/#post-12484503)
 * [According to the WordPress Codex](https://codex.wordpress.org/Shortcode_API#Nested_Shortcodes),
   the parser will fail when two shortcodes with the same name are nested:
 * > However 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:
 *     ```
       [tag-a]
          [tag-b]
             [tag-c]
          [/tag-b]
       [/tag-a]
       ```
   
 * but you can’t do this:
 *     ```
       [tag-a]
          [tag-a]
          [/tag-a]
       [/tag-a]
       ```
   
 * However, as of version 4.3, Private Content has [two shortcodes](https://github.com/aldolat/private-content/wiki#the-shortcode-command)
   that you can use:
 * `[private]` and `[ubn_private]`.
 * In other words, you can use both `[private]` and `[ubn_private]`.
 * This means that you could use these two shortcodes for your nesting purposes,
   for example:
 *     ```
       [private]
          [ubn_private]
          [/ubn_private]
       [/private]
       ```
   
 * I can’t try this now, but please let me know if you can.
 *  Thread Starter [songiuno](https://wordpress.org/support/users/songiuno/)
 * (@songiuno)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/nesting-the-shortcode/#post-12489319)
 * I struggled with the nesting test but finally got it to work. So yes it does 
   work as you mentioned. Problem solved!
    -  This reply was modified 6 years, 2 months ago by [songiuno](https://wordpress.org/support/users/songiuno/).
 *  Plugin Author [Aldo Latino](https://wordpress.org/support/users/aldolat/)
 * (@aldolat)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/nesting-the-shortcode/#post-12491970)
 * Wow, great! Thank you [@songiuno](https://wordpress.org/support/users/songiuno/)!

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

The topic ‘Nesting the 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/)

 * 3 replies
 * 2 participants
 * Last reply from: [Aldo Latino](https://wordpress.org/support/users/aldolat/)
 * Last activity: [6 years, 2 months ago](https://wordpress.org/support/topic/nesting-the-shortcode/#post-12491970)
 * Status: resolved