Title: Expandable/collapsable categories?
Last modified: August 18, 2016

---

# Expandable/collapsable categories?

 *  [paulritter](https://wordpress.org/support/users/paulritter/)
 * (@paulritter)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/expandablecollapsable-categories/)
 * Hi, I’ve searched far and wide for a code to do this, and I’ve found some, but
   couldn’t figure out how to use them.
 * What I’m looking for is to be able to set certain categories of mine to be automatically
   collapsed when someone views my site, but with a “+” button beside them to expand
   them if they so wish. I want to clarify that I want to be able to specify which
   categories I want to automatically be collapsed, I don’t want all of them to 
   do it.
 * I found these: [http://www.webspaceworks.com/resources/cat/wp-plugins/31/](http://www.webspaceworks.com/resources/cat/wp-plugins/31/),
   and [http://www.webspaceworks.com/resources/cat/wp-plugins/30/](http://www.webspaceworks.com/resources/cat/wp-plugins/30/)
   but I couldn’t figure out how to work either one; in the instructions they provided
   to do, no such code existed in my sidebar.php file that they said to replace.
 * Please help? Thanks! 🙂

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

 *  [Ajay](https://wordpress.org/support/users/ajay/)
 * (@ajay)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/expandablecollapsable-categories/#post-308194)
 * `wp_list_cats` lists the categories in your sidebar.
 * If you don’t have that in your sidebar you don’t need to worry.
 * Just add `<?php wswwpx_fold_category_list(); ?>` as the plugin page says to display
   the categories.
 *  Thread Starter [paulritter](https://wordpress.org/support/users/paulritter/)
 * (@paulritter)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/expandablecollapsable-categories/#post-308399)
 * Hi, thanks for replying. Umm, I guess I shouldn’t have used categories as the
   word.
 * I’ve got literally a ton of links and stuff in my sidebar. So many, in fact, 
   that it lengthens the page past the articles I have written. You can see it at:
   [http://www.paulritter.co.nr](http://www.paulritter.co.nr). I’m using another
   plugin called post-tease or something, and it basically shortens every entry 
   and gives people the option of reading the entire thing or not. But now that 
   I use this, all my links drag the length of my page waaaay down. I want to be
   able to have those “link categories” be automatically collapsed, not the actual
   categories list.
 * Is there a way? Thanks
 *  [Mark (podz)](https://wordpress.org/support/users/podz/)
 * (@podz)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/expandablecollapsable-categories/#post-308400)
 * I use one way:
    [http://www.tamba2.org.uk/T2/](http://www.tamba2.org.uk/T2/) 
   check the archives and category links.
 * The method is described here:
    [http://www.tamba2.org.uk/wordpress/collapse/](http://www.tamba2.org.uk/wordpress/collapse/)
 * It’s not perfect but it might be a pointer to the answer ?
 *  Thread Starter [paulritter](https://wordpress.org/support/users/paulritter/)
 * (@paulritter)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/expandablecollapsable-categories/#post-308500)
 * Aha, yes, that’s exactly what I want, as long as I can make it collapse other
   things on the sidebar, not just Archives and Categories.
 * And I’m kind of confused about how to work that code…can you explain it to me
   how I install all those bits and where? Thanks!!!
 *  [Edd](https://wordpress.org/support/users/edd/)
 * (@edd)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/expandablecollapsable-categories/#post-308529)
 * Ok so if you look at the second link podz posted you’ll see a guide to achieve
   this.
    So the first thing you want to do is get your FTP client open and create
   a new folder called “hacks”. Create it under the wp-content folder. Once you’ve
   done this, you want to open up notepad and paste this code into it: `function
   kadabra(zap) { if (document.getElementById) { var abra = document.getElementById(
   zap).style; if (abra.display == "block") { abra.display = "none"; } else { abra.
   display = "block" } return false } else { return true } }
 * Under file type, select “all files” and name it “kadabra.js” save it somewhere
   memorable and close notepad.
 * Return to your FTP client and upload the file you just created to the folder 
   you just created (wp-content/hacks)
 * Now you want to navigate to /wp-content/themename/ and open up header.php for
   editing.
    In header.php you want to add this code: `<script type="text/javascript"
   src="http://www.paulritter.co.nr/wp-content/hacks/kadabra.js"> </script> Imbetween
   the “<head>” and “</head>” tags. Save your changes and close header.php. Now 
   open up “style.css” and add #m1, #m2, #m3, #m4 { display: none; } to the bottom
   of the style.
 * Now you said you wanted to collapse the links section, this is where I need someone
   else to fill in the last bit. See, the links header isn’t coded in the same way
   as “Categories” (at least not for me). I’ll have a look myself and post back 
   but if anyone knows themselves, please post here to finish off my quick guide.
 * Hope that helps, post back with any problems.
 *  Thread Starter [paulritter](https://wordpress.org/support/users/paulritter/)
 * (@paulritter)
 * [20 years, 5 months ago](https://wordpress.org/support/topic/expandablecollapsable-categories/#post-308590)
 * Still won’t work.
 * Oh well, don’t bother. I’m cleaning up my site anyways, there was way to much
   stuff on it. Thanks anyways.
 *  [chickspirit](https://wordpress.org/support/users/chickspirit/)
 * (@chickspirit)
 * [20 years ago](https://wordpress.org/support/topic/expandablecollapsable-categories/#post-308909)
 * Hi ~
 * Edd said:
 *  “Now you said you wanted to collapse the links section, this is where I need
   someone else to fill in the last bit. See, the links header isn’t coded in the
   same way as “Categories” (at least not for me). I’ll have a look myself and post
   back but if anyone knows themselves, please post here to finish off my quick 
   guide.”
 * Does anyone have the answer as to how to apply the javascript from tamba2.org.
   uk/T2/ to the links section?
 *  [naifyboy](https://wordpress.org/support/users/naifyboy/)
 * (@naifyboy)
 * [19 years, 11 months ago](https://wordpress.org/support/topic/expandablecollapsable-categories/#post-308916)
 * i have also tried the code in
    tamba2.org.uk/wordpress/collapse/
 * doesnt change a thing for me.
 * have treble checked my code and the paths to the script etc…still no good…there
   must be loads of us who want to do this..
 * anyone have any ideas?
 * thanks
 *  [Rok](https://wordpress.org/support/users/rok/)
 * (@rok)
 * [19 years, 11 months ago](https://wordpress.org/support/topic/expandablecollapsable-categories/#post-308917)
 * I am using tamba2.org.uk/T2/ script from the days of WordPress 2.0 till date.
   And I have no problems. It is very flexible and customizable.
 *  [silpstream](https://wordpress.org/support/users/silpstream/)
 * (@silpstream)
 * [19 years, 11 months ago](https://wordpress.org/support/topic/expandablecollapsable-categories/#post-308918)
 * Try the plugin I wrote:
 * [http://www.silpstream.com/blog/wp-dtree/](http://www.silpstream.com/blog/wp-dtree/)

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

The topic ‘Expandable/collapsable categories?’ is closed to new replies.

## Tags

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

 * 10 replies
 * 8 participants
 * Last reply from: [silpstream](https://wordpress.org/support/users/silpstream/)
 * Last activity: [19 years, 11 months ago](https://wordpress.org/support/topic/expandablecollapsable-categories/#post-308918)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
