Title: Inserting PHP inside do_shortcode
Last modified: August 21, 2016

---

# Inserting PHP inside do_shortcode

 *  Resolved [jasonreider](https://wordpress.org/support/users/jasonreider/)
 * (@jasonreider)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/inserting-php-inside-do_shortcode/)
 * I am trying to use an existing shortcode for an accordion element with opening
   and closing shortcodes in a custom template for my wordpress site. Basically,
   I need to insert PHP arrays inside this shortcode, like so:
 *     ```
       <php do_shortcode('[vc_accordion]';>
       PHP arrays here
       <php do_shortcode('[/vc_accordion]';>
       ```
   
 * Does anyone know if a solution?

Viewing 1 replies (of 1 total)

 *  [SpankMarvin](https://wordpress.org/support/users/spankmarvin/)
 * (@spankmarvin)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/inserting-php-inside-do_shortcode/#post-5070188)
 * You should do this via hooks if you can. Take a look at the shortcode function
   for the existing accordian shortcode and see if it’s pluggable. If so, simply
   add_action or add_filter into that with your custom function and arrays. If not,
   copy the shortcode function, remove the shortcode and then re-add it with the
   copied-and-renamed function for the overriding shortcode, which would add your
   arrays.
 * At least, I think that’s how you’d want to do it.
 * Make sense?
 * J

Viewing 1 replies (of 1 total)

The topic ‘Inserting PHP inside do_shortcode’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [SpankMarvin](https://wordpress.org/support/users/spankmarvin/)
 * Last activity: [11 years, 11 months ago](https://wordpress.org/support/topic/inserting-php-inside-do_shortcode/#post-5070188)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
