Title: Using [shortcode] inside [accordion]
Last modified: August 21, 2016

---

# Using [shortcode] inside [accordion]

 *  [pauldory](https://wordpress.org/support/users/pauldory/)
 * (@pauldory)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/using-shortcode-inside-accordion/)
 * I’m curious if anyone knows if this is possible.
    Can you use a shortcode inside
   the accordion shortcode, like this (**see below _sitenameshortcode_**):
 *     ```
       [accordions title="" disabled="false" autoheight="false" collapsible="true"]
         [ accordion title="MyTitleText" [sitenameshortcode] ]
          Some Text
         [/accordion]
       [/accordions]
       ```
   
 * [http://wordpress.org/plugins/squelch-tabs-and-accordions-shortcodes/](http://wordpress.org/plugins/squelch-tabs-and-accordions-shortcodes/)

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

 *  Plugin Author [Matt Lowe](https://wordpress.org/support/users/squelch/)
 * (@squelch)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/using-shortcode-inside-accordion/#post-4286662)
 * No, the WordPress shortcodes engine is too simplistic for that. While I can see
   it would be useful if it could do this, the “dumb” way in which it’s been built
   is with an emphasis on speed.
 *  Thread Starter [pauldory](https://wordpress.org/support/users/pauldory/)
 * (@pauldory)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/using-shortcode-inside-accordion/#post-4286669)
 * Matt … Many places I am using [sitename] as my shortcode … between the accordion
   shortcode tags I can use [sitenameshortcode] but within the [accordions] this
   is a no go …
 * Is it a limitation by WP or the plugin?
 * To make it easier for the editors, I have applied the shortcode rule for them,
   and was hoping there was some solution that would allow that same shortcode to
   be used within (not between) other shortcodes …
 * In this case, should they ever want to change the name of the site, I figured
   using shortcode would be perfect .. then I came upon the issue with the accordion
   plugin …
 * Thanks for your help!
 *  Plugin Author [Matt Lowe](https://wordpress.org/support/users/squelch/)
 * (@squelch)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/using-shortcode-inside-accordion/#post-4286673)
 * It is a limitation by WP, there is nothing my or any other plugin can do to work
   around this. The WordPress shortcodes engine is too simplistic to do what you’re
   trying to achieve because it’s been built with an emphasis on speed.
 * See [http://codex.wordpress.org/Shortcode_API#Limitations](http://codex.wordpress.org/Shortcode_API#Limitations)
   
   and [http://codex.wordpress.org/Shortcode_API#Square_Brackets](http://codex.wordpress.org/Shortcode_API#Square_Brackets)
 * Note that the square brackets rule applies to square brackets ANYWHERE within
   a shortcode.
 *  Thread Starter [pauldory](https://wordpress.org/support/users/pauldory/)
 * (@pauldory)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/using-shortcode-inside-accordion/#post-4286676)
 * Again, thank you …. and great plugin!
 *  Plugin Author [Matt Lowe](https://wordpress.org/support/users/squelch/)
 * (@squelch)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/using-shortcode-inside-accordion/#post-4286678)
 * Out of interest what is the output of the `[sitename]` shortcode?
 *  Thread Starter [pauldory](https://wordpress.org/support/users/pauldory/)
 * (@pauldory)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/using-shortcode-inside-accordion/#post-4286683)
 * It outputs the name of the site, for instance if it were MySiteName, I defined
   my function to use this as the name wherever the code is used with styling.
 * However when used inside the [accordion], it renders blank until it comes to 
   another opening/closing shortcode then continues correctly after that.
 * It’s purpose is probably obvious … allowing for the formatting, and naming of
   the site across all pages and should it ever be changed, it’s editted in one 
   place and the update is across the board.
 *     ```
       function post_sitename() {
       	return '<em>MySiteName</em>';
       }
       add_shortcode('sitename', 'post_sitename');
       ```
   
 *  Plugin Author [Matt Lowe](https://wordpress.org/support/users/squelch/)
 * (@squelch)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/using-shortcode-inside-accordion/#post-4286690)
 * Your original example doesn’t quite make sense then:
 *     ```
       [ accordion title="MyTitleText" [sitenameshortcode] ]
          Some Text
         [/accordion]
       ```
   
 * If WordPress did allow shortcodes within shortcodes then that would become
 *     ```
       [ accordion title="MyTitleText" <em>MySiteName</em>]
          Some Text
         [/accordion]
       ```
   
 * …which doesn’t make any sense.
 * This would make more sense:
 *     ```
       [ accordion title="MyTitleText [sitenameshortcode]" ]
          Some Text
         [/accordion]
       ```
   
 * But again, sadly this is not currently possible with WordPress. If you really
   wanted to be able to do something technically equivalent to this then you could
   write a new shortcode, call it `myaccordion` for example, which would be used
   in place of `[accordion]`. Its only job would be to replace a specific string,`%
   sitename%` perhaps with the site name, before passing on the content to the function`
   squelch_taas_accordion_shortcode()`.
 * Then all you’ve got to do is make sure everyone is using `[myaccordion]` in place
   of `[accordion]` and understands they have to use `%sitename%` in place of `sitenameshortcode`.
   But you’re probably going to find you have to do this for every shortcode on 
   your website to make it viable, which would likely get out of hand fast.
 *  Thread Starter [pauldory](https://wordpress.org/support/users/pauldory/)
 * (@pauldory)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/using-shortcode-inside-accordion/#post-4286692)
 * Typo on my part, [sitenameshortcode] and [sitename] are the same …

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

The topic ‘Using [shortcode] inside [accordion]’ is closed to new replies.

 * ![](https://ps.w.org/squelch-tabs-and-accordions-shortcodes/assets/icon.svg?rev
   =3054409)
 * [Squelch Tabs and Accordions Shortcodes](https://wordpress.org/plugins/squelch-tabs-and-accordions-shortcodes/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/squelch-tabs-and-accordions-shortcodes/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/squelch-tabs-and-accordions-shortcodes/)
 * [Active Topics](https://wordpress.org/support/plugin/squelch-tabs-and-accordions-shortcodes/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/squelch-tabs-and-accordions-shortcodes/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/squelch-tabs-and-accordions-shortcodes/reviews/)

## Tags

 * [embed shortcode](https://wordpress.org/support/topic-tag/embed-shortcode/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)
 * [shortcode in shortcode](https://wordpress.org/support/topic-tag/shortcode-in-shortcode/)

 * 8 replies
 * 2 participants
 * Last reply from: [pauldory](https://wordpress.org/support/users/pauldory/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/using-shortcode-inside-accordion/#post-4286692)
 * Status: not a support question