Title: [Plugin: Accordion Shortcode] Collapse all
Last modified: August 20, 2016

---

# [Plugin: Accordion Shortcode] Collapse all

 *  [jdev](https://wordpress.org/support/users/jdev/)
 * (@jdev)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-accordion-shortcode-collapse-all/)
 * Is there a way to collapse all content in the accordion by default?
 * [http://wordpress.org/extend/plugins/accordion-shortcode/](http://wordpress.org/extend/plugins/accordion-shortcode/)

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

 *  [blueairplane](https://wordpress.org/support/users/blueairplane/)
 * (@blueairplane)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-accordion-shortcode-collapse-all/#post-2852137)
 * Great plugin – but I’m really trying to do the same – anyone have luck with this?
 * Using [accordions active=0] just doesn’t do anything.
 * Thanks for any ideas!
 *  [bdell](https://wordpress.org/support/users/bdell/)
 * (@bdell)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-accordion-shortcode-collapse-all/#post-2852150)
 * I am needing the same thing!
 *  [AndyWarren](https://wordpress.org/support/users/awarren/)
 * (@awarren)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-accordion-shortcode-collapse-all/#post-2852167)
 * For this plugin to show all of the accordion items as collapsed when the page
   first renders you need to make a couple changes to the plugin code. I had the
   same issue as you guys for about an hour today. Open your plugins directory and
   then open the accordion-shortcode directory, and then finally open accordion-
   shortcode.php.
 * Look for this line, its line 53 in my editor:
    `$attr['active'] = (int)$attr['
   active'];`
 * Change it to:
    `$attr['active'] = (bool)$attr['active'];`
 * Then look for this line, its line 61 in my editor:
    `'active' => 0,`
 * Change it to:
    `'active' => false,`
 * Then on your accordion, make sure you set the shortcode to:
    `[accordions collapsible
   =true]`
 * This just worked for me, hope it helps.
 *  [stacey6](https://wordpress.org/support/users/stacey6/)
 * (@stacey6)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/plugin-accordion-shortcode-collapse-all/#post-2852188)
 * awarren – Thanks for posting this. Worked like a charm!!!
 *  [akhayyat](https://wordpress.org/support/users/akhayyat/)
 * (@akhayyat)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/plugin-accordion-shortcode-collapse-all/#post-2852201)
 * Found an easier workaround: Use a very large value for `active`:
 * `[accordions active=100 collapsible=true]`
 *  [vijilov](https://wordpress.org/support/users/vijilov/)
 * (@vijilov)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/plugin-accordion-shortcode-collapse-all/#post-2852207)
 * hey i tried -1. its working!
    try this,
 * [accordions active=-1]
 *  [akhayyat](https://wordpress.org/support/users/akhayyat/)
 * (@akhayyat)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/plugin-accordion-shortcode-collapse-all/#post-2852210)
 * For me, -1 expands the last accordion.
 * The only thing that works for me is:
 * `[accordions active=100 collapsible=true]`
 * (assuming you have fewer than 100 accordions)
 *  [Peterkopi](https://wordpress.org/support/users/peterkopi/)
 * (@peterkopi)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/plugin-accordion-shortcode-collapse-all/#post-2852213)
 * I am also trying to have all collapsed when the page is loaded, but the script
   must have been edited, because I can’t find
 * `$attr['active'] = (int)$attr['active'];`
 * on line 53, which now is showing:
 *  `'class' => null,`
 * akhayyat’s workaround did NOT work for me.
 * Can anybody help, please?
 *  [Peterkopi](https://wordpress.org/support/users/peterkopi/)
 * (@peterkopi)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/plugin-accordion-shortcode-collapse-all/#post-2852214)
 * In version Version: 1.2.1 I can find this on line 101-130:
 *     ```
       public static function accordions_shortcode( $atts, $content ) {
   
       		self::$add_script = true;
       		if( is_string($atts) )
       			$atts = array();
   
       		$attr['autoHeight'] = self::eval_bool( $atts['autoheight'] );
       		$attr['disabled']  	= self::eval_bool( $atts['disabled'] );
       		$attr['active']  	= (int)$atts['active'];
       		$attr['clearStyle'] = self::eval_bool( $atts['clearstyle']);
       		$attr['collapsible']= self::eval_bool( $atts['collapsible']);
       		$attr['fillSpace'] 	= self::eval_bool( $atts['fillspace']);
   
       		$query_atts = shortcode_atts( array(
       				'autoHeight'  => false,
       				'disabled'   => false,
       				'active'  => 0,
       				'animated'   => 'slide',
       				'clearStyle'  => false,
       				'collapsible'  => false,
       				'event'   => 'click',
       				'fillSpace'  => false
       			), $attr);
       		$id = "random-accordion-id-".rand(0,1000);
   
       		$content = str_replace( "]<br />","]", ( substr( $content, 0 , 6 ) == "<br />" ? substr( $content, 6 ): $content ) );
   
       		self::$shortcode_js_data[$id] = $query_atts;
   
       		return str_replace("\r\n", '', '<div id="'.$id.'" class="accordions-shortcode">'.do_shortcode( $content ).'</div>');
       ```
   
 * Maybe it’s somewhere around here I need to change the script to laod collapsed?
 *  [AndyWarren](https://wordpress.org/support/users/awarren/)
 * (@awarren)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/plugin-accordion-shortcode-collapse-all/#post-2852215)
 * [@peterkopi](https://wordpress.org/support/users/peterkopi/) –
 * Change your line 109 to `$attr['active'] = (bool)$attr['active'];`
 * Then change your line 117 to `'active' => false,`
 * And Finally, display your accordion with `[accordions collapsible=true]` as the
   opening shortcode. Let me know if this works, I haven’t used this plugin for 
   quite some time.

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

The topic ‘[Plugin: Accordion Shortcode] Collapse all’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/accordion-shortcode.svg)
 * [Accordion Shortcode](https://wordpress.org/plugins/accordion-shortcode/)
 * [Support Threads](https://wordpress.org/support/plugin/accordion-shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/accordion-shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/accordion-shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/accordion-shortcode/reviews/)

## Tags

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

 * 10 replies
 * 8 participants
 * Last reply from: [AndyWarren](https://wordpress.org/support/users/awarren/)
 * Last activity: [13 years, 1 month ago](https://wordpress.org/support/topic/plugin-accordion-shortcode-collapse-all/#post-2852215)
 * Status: not resolved