Title: Using accordions in php template
Last modified: May 18, 2019

---

# Using accordions in php template

 *  Resolved [sorro445](https://wordpress.org/support/users/sorro445/)
 * (@sorro445)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/using-accordions-in-php-template/)
 * Hi,
    I was wondering if there is any way to use an accordion in a woocommerce
   php template(inside a table).
 * Thank you!

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

 *  Plugin Author [philbuchanan](https://wordpress.org/support/users/philbuchanan/)
 * (@philbuchanan)
 * [7 years ago](https://wordpress.org/support/topic/using-accordions-in-php-template/#post-11559628)
 * Yes! Just put your entire accordion content as a param of the [`do_shortcode()`](https://developer.wordpress.org/reference/functions/do_shortcode/)
   function:
 * e.g.:
 *     ```
       $accordion = '[accordion]
       [accordion-item title="Title of accordion item"]Drop-down content goes here.[/accordion-item]
       [accordion-item title="Second accordion item"]Drop-down content goes here.[/accordion-item]
       [/accordion]';
   
       echo do_shortcode($accordion); ?>
       ```
   
    -  This reply was modified 7 years ago by [philbuchanan](https://wordpress.org/support/users/philbuchanan/).
 *  Thread Starter [sorro445](https://wordpress.org/support/users/sorro445/)
 * (@sorro445)
 * [7 years ago](https://wordpress.org/support/topic/using-accordions-in-php-template/#post-11560545)
 * Hi,
    thanks. I would need to have the content of the accordion be PHP though 
   as well…is this possible?
 *  Plugin Author [philbuchanan](https://wordpress.org/support/users/philbuchanan/)
 * (@philbuchanan)
 * [7 years ago](https://wordpress.org/support/topic/using-accordions-in-php-template/#post-11568939)
 * Yes. You just need to create the string using PHP:
 *     ```
       <?php 
   
       $accordion = '[accordion]';
       $accordion .= '[accordion-item title="' . $your_title_here . '"]';
       $accordion .= ''; // Your PHP code for the content of the first item goes here
       $accordion .= '[/accordion-item]';
       $accordion .= '[/accordion]';
   
       echo do_shortcode($accordion); 
   
       ?>
       ```
   
 *  Thread Starter [sorro445](https://wordpress.org/support/users/sorro445/)
 * (@sorro445)
 * [7 years ago](https://wordpress.org/support/topic/using-accordions-in-php-template/#post-11569678)
 * Hi,
    thank you so much for helping. Unfortunately I can’t get it to work, even
   the first code without PHP does not display a useable accordion – headline and
   content are displayed at the sae time, and you cannot close or open it. Maybe
   Woocommerce does not allow it?
 * The thing I a trying to achieve is to have the accordion title “description” 
   underneath each product in the checkout order table, and when you click on it
   the accordion should open and the product description and image should be displayed(
   by default, Woocommerce does not display anything besides the product name in
   the checkout table).
 * My knowledge in PHP is limited but I am really desperate in getting this to work…

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

The topic ‘Using accordions in php template’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/accordion-shortcodes.svg)
 * [Accordion Shortcodes](https://wordpress.org/plugins/accordion-shortcodes/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/accordion-shortcodes/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/accordion-shortcodes/)
 * [Active Topics](https://wordpress.org/support/plugin/accordion-shortcodes/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/accordion-shortcodes/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/accordion-shortcodes/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [sorro445](https://wordpress.org/support/users/sorro445/)
 * Last activity: [7 years ago](https://wordpress.org/support/topic/using-accordions-in-php-template/#post-11569678)
 * Status: resolved