Collapsing Categories

The collapsing categories plugin creates a list of all categories, subcategories, and posts, which can be expanded and collapsed dynamically, as you can see in the sidebar on this page.

The plugin is hosted on the official WordPress repository at:

If you have any questions, bug reports, or feature requests, please visit the Frequently Asked Questions, and at the other comments here (find is your friend)).

Your appreciation

If you really like my plugins, please give them a nice ranking in the wordpress plugin repository (links above), or you can send me a donation via paypal below:

240 Responses to Collapsing Categories

  1. robfelty says:


    The reason I used the 3-way equals because otherwise I got some duplicate results, as you mention. Using three separate 2-way equals with AND still returns a few duplicates for me, but then adding a GROUP BY gets rid of them. Obviously the 3-way works fine for me, but apparently it does not work in all versions of mysql. I am not an SQL expert by any means.

    I have changed the query in 0.8.3. Hopefully this will work for more people.


  2. watson says:

    Well we are getting much closer. Two updates in one week that is a lot of work! Nice job Rob. It is now almost working for me.

    Problem: After upgrading to CC 0.8.3 the widget now appears in the side bar, but only 4 of my 12 categories show up.

    Suggestion: Would be nice if users could click an option to remove or keep the “>>” that shows up the left of their categories. The >> is not needed because of your other expanding icon options.


  3. robfelty says:


    Thanks for the encouraging words. There seems to be some issues with the SQL query to grab categories. Both 0.8.2 and 0.8.3 were working fine for me. I want to hear what some other people have to say about 0.8.3. I am hopeful that we can find a query that seems to work for everyone. If there are any SQl wizards listening, I would not turn down some help :)

    As far as the option you suggest, there are already so many options, that I don’t want to add a bunch of style-specific options. You can change the style settings from the settings page now. I think the default settings I have should now display the >> before items that expand and collapse, but it should before items which have no subitems.


  4. watson says:

    Thanks Rob. In the meantime. What line would I remove from the >> from the style settings. Just checked it and didn’t see anything that reads “>>”. Checked a few of your php and css files. Closest thing I found was:

    #sidebar li.collapsCat:before {content:”;}

  5. Rob,
    I don’t know if my problem is caused by a problem with SQL or not. I don’t do anything beyond CSS and HMTL. But while your Archives and Links plugins work fine for me, the Collapsing Categories is not even close. I have installed 0.8.3 and there is no change in the behavior. I have left it on my sidebar, with the debug option enabled, but I don’t know how to interpret what is being put out.

    @watson, comment out this line in the css on the options page:

    #sidebar li.collapsCatPost:before {content: '\00BB \00A0' !important;}

    That should remove the >> from your links.

  6. Jessie Angel says:

    YAY! So with your latest update, my sidebar looks like it’s supposed to. I know others are still having issues, but I seem to be doing okay so far. Thanks for the fix!

  7. Joe says:


    I tried both 0.8.2 and 0.8.3 and have the same results, nothing shows up no matter if I include any categories in the include section or not. I have no problems with collapsing archives or pages.


  8. Philip says:

    Hi Rob. Me again.

    All through the recent version releases, CC has been working fine for me and I’ve been wondering why other people have been having problems. But with 0.8.3 it’s stopped working: Once the category has been expanded, the little expand / collapse symbol disappears so that you can’t collapse the category any more. I’ve uninstalled and reinstalled a couple of times, and played with the settings just to make sure.

    0.8.3 is on my test site here while 0.8.2 is on my live site working just fine.

    Happy New Year to you

  9. robfelty says:


    I think I figured out the problem. You are not actually using categories on your blog. You are only using tags. Collapsing Categories WAS only looking for categories. I have now added an option to list categories, tags, or both. The default is still to only list categories. My hunch is that this should fix the problem for many others too.

    Please download the development version. If it seems to be working for people, I will call it 0.8.4.


  10. Joe says:

    Rob I am using categories, the most recent post was posted in ‘Regulations & Legislative’ and the post before that in ‘All tied up’. If I enable the WP categories widget it populates and works fine. I enabled that on the left sidebar and left yours on the right.


  11. robfelty says:


    Indeed you are using categories. Thanks for your patience. I think I have it all figured out now. If you wouldn’t mind, please re-download the development version, and see if it is working for you now.

    @Philip – I don’t see the collapsing categories widget at all on your test site.


  12. Philip says:

    Hi Rob
    I’ve moved it top left and renamed it to make it obvious!
    It works just about OK in IE7 (though the mouse arrow doesn’t behave ideally on hover), but flock / firefox / chrome / safari / opera / seamonkey all have the problem where the little icon vanishes when you expand, which means you can’t collapse it again.

  13. robfelty says:


    I think I was getting a cached page. After clicking on a page other than the front page, I saw collapsing categories.

    It turns out that another plugin is causing the issue – there is a style sheet called gigpress.css that defines

    span.hide {display:none}

    I use the class ‘collapsCat hide’ to indicate that it should be collapsed. If you add the following to your css, the problem goes away:

    span.collapsCat.hide {display:inline}

    Also, it looks like there is no style defined for collapsCat at all. Check the settings page to set the style.


  14. Philip says:

    Thanks for the swift and accurate analysis Rob
    I deactivated the conflicting plugin, pressed “restore original style” in the settings page and everything’s working fine now. Thanks a lot.
    I’ll bear your css tweak in mind if I ever go live with gigpress.
    Best wishes

  15. Joe says:


    With the dev version it seems they show up nested under each other.


  16. robfelty says:


    I think I found that bug. Please try the development version one more time.

    Thanks for your help in debugging. (Also, could you turn the debugging option on in your blog?)


  17. Joe says:


    Downloaded it and turned on debugging. The categories themselves look good now but the content under them looks a little mixed up…no the right posts under the right categories.


  18. Rob,

    I just tried the Development build off of WordPress. I had to use FTP to delete the existing Collapsing Categories directory, WordPress couldn’t upload and open the zip.

    When I tried it on my site, it still just nested the categories. It would include the right ones, and give the correct number of posts, but it just nested the categories. I found that by using the Expanding Shows: Just Sub-categories, it would put up an unordered list of the included categories, but they all would just go to the category archive, even when the option for expanding when clicking on the category name was used.

    Currently, it almost works for the one category (reviews) that has sub-categories. But there are 2 sub-categories under it (music and books) and only one shows, plus it has any categories that come under it in the nested.

    Debug is on, so if you want to take a look, good luck.

  19. Mitch Berger says:


    When we last left my story, I replaced the three way join with two joins separated by an “=” along with a “SELECT DISTINCT”. However, I now have subcategories disappearing from my list.

    Let me know if you want any more info, and what I can do to help. I have debug on, if you wish to take a look.


  20. robfelty says:

    screenshot of toms categories

    It seems to be working ok for me on Firefox. Is this what you were expecting?

    screenshot of aishdas categories
    What subcategories are missing? This is what I see.


    Could you tell me what posts you are expecting to show up in your “tackle” category? I am still having trouble figuring out what is going on there.


  21. Rob,

    No that is not correct. Reviews is a parent category, but there are only 2 sub-categories under it, music and books. It is showing music, games, comic books, and humor as sub-categories, but books is not showing. Games, comic books, and humor are all parent categories. If I change the sort order so Reviews is at the top of the list, all of my other categories will show up under it as sub-categories on your list.

    Here are the settings I have for that list. Notice that posts are supposed to be showing? But the debug says that is set to no.

    I have added the regular WordPress Category drop down so you can see what my actual categories are. The shorter list on the collapsing one is because I have only included some of them for testing.

  22. Mitch Berger says:


    It seems that Tom and I are seeing similar symptoms.

    Here’s the full hierarchy as taken from the blog’s config pages:

    audio   15
    chumash 1
            bamidbar        9
            bereishis       9
            devarim 3
            shemos  3
            vayiqra 4
    machashavah     5
            absolutism      7
            creation        6
            eschatology     5
                    geulah  1
            faith-and-proof 8
            forks   9
            fundamentals    14
            halachah        0
                    process 17
                    taamei-hamitzvos        16
                            clothing        3
                            holidays        25
                                    pesach  13
            reward-and-punishment   4
            science-and-torah       3
            theology        6
                    theodicy        7
    mussar  4
            deios   21
            history 2
            middos  13
                    ahavah  7
                    anavah  7
                    anger   5
                    aveilus 3
                    bitachon        9
                    simchah 7
                    yirah   3
            teshuvah        9
            tools   5
            torah-as-growth 6
            ufem    3
    psyche  17
            naran   6
                    qedushah        3
                    taharah 3
    tefillah        6
            amidah  5
            daily   9
            preparation     1
            shabbos 6
            shacharis       5
            shema   9
            yom-tov 15
    uncategorized   10


  23. robfelty says:


    Maybe my option labeling is misleading. You do indeed have it set to show only sub-categories, not posts. Look at the setting which says “Expanding shows:”. If you posts to show up, you should select “Sub-categories and posts”.


    Thanks for the hierarchy. I am still confused though. I can navigate to “pesach” just fine with your collapsing category widget, which is pretty deeply nested. Is there a specific subcategory that is missing?


  24. Mitch Berger says:

    Doing a diff, I found that what is missing from the page is “Mussar->Middos” and its subcategories. Mussar is a parent level category, so this is only one level down. It is in the debug output hidden on my home page.

    (I guess it’s the problem Diogenes faced :-) — I can’t find the section on refining one’s virtues!)


  25. Rob,

    No, I just forgot, I had it set to not show posts on the first option, because if I change that setting, this is what it looks like. Note that there are still no posts showing, and debug says posts are not supposed to appear. And everything is nested under everything above it. The only option I changed was the Expanding Shows: option to show both Sub-categories and Posts.

    I have it with those options on my site right now.

  26. robfelty says:

    @Tom and Mitch,

    Tom lent me his database, which was very nice for debugging help. I spent quite a bit of time playing around with the queries, and I think I have them working now. I did a test install of wordpress using Tom’s database, and it seems to be working. Please give the development version one more try.



  27. Joe says:


    The latest build looks like it has fixed my issues as well. No more nesting other top level categories and the correct posts showing under their categories. I have to do a little more checking to verify but at first glance it looks great.

    Thanks for all your efforts on this.


  28. Mitch Berger says:


    Thanks. The development version is working for me.

    Now, since I can’t just leave you alone, a feature request: If a category contains posts as well as sub-categories, could there be an option for creating a “General” or “Miscellaneous” entry for grouping them into one place?


  29. JeZZoo says:

    After update to latest version of plugin I’ve got no category in widget. When I enable debug in source is a list of categories in debug part but none on list.
    This part of code looks like:

    <li id="collapscat-328988982" class="widget collapsCat"><h2>Categories</h2>
        <ul id='collapsCatList'>
    <pre style='display:none' >MySQL server version: 5.0.41
     SELECT sz_term_taxonomy.count as 'count',
          sz_terms.term_id,, sz_terms.slug,
          sz_term_taxonomy.parent, sz_term_taxonomy.description
          FROM sz_terms, sz_term_taxonomy, sz_term_relationships
          WHERE sz_terms.term_id = sz_term_taxonomy.term_id
          AND sz_terms.term_id  = sz_term_relationships.object_id
          AND sz_term_taxonomy.term_id  = sz_term_relationships.object_id
          AND != 'Blogroll' AND
          sz_term_taxonomy.taxonomy = 'category' ''
          GROUP BY sz_terms.term_id ORDER BY

        [0] => stdClass Object
                [count] => 72
                [term_id] => 10

    <in this place is correct list of categories)

    What should i check to resolve problem.

  30. Rob,

    No joy here. With these settings, I get this on page load and this when I expand everything. Posts still don’t show no matter how I set it. If if is working on the copy of my database, then there must be something else, probably another plugin, on my site screwing with it.

  31. robfelty says:

    @Jezzoo – I’m working on fixing these issues. Please try the development version.

    @Tom – look here:
    (and do one more update). My guess is that it might have to do with your old version of mysql, since the postquery is not returning anything. I don’t have an old version of mysql to play around with. One tip. I tried removing DISTINCT from the postquery in collapscatlist.php, and it doesn’t seem to display duplicates. Maybe that would work with mysql 4.0


  32. robfelty says:

    @Mitch, that is a good idea for a feature. It might take me awhile to work on it though.


  33. Rob,

    I did another download and install of the development version. No change at all. I removed the distinct from the postquery, it didn’t seem to change anything either. On that testblog, the listing looks good, but nothing happens when I click on anything. Is that supposed to be like that?

    I am thinking I really need to set up a test blog and go through my plugins. I know of at least one intermittent problem that screws with my dashboard if I load any of 3 plugins.

  34. amenity says:

    Can I use this widget outside of the sidebar as well? It works so beautifully, I’d like to have it on a page to browse categories.

  35. robfelty says:


    Whoops, I just realized I had the ‘home’ set wrong in the database. That test site should look better now. Here is my suggestion. Set up a brand new wp 2.7 install, and try it out that way. I still think it might have to do with the version of mysql.


    Currently the plugin is designed to be used either as a widget or manually, but not both. Here is a workaround. Find out the id number of your collapsing category widget by looking at the html source. You should see something like:

    <li id="collapscat-299723351" class="widget collapsCat"><h2 class="widgettitle">Categories</h2>

    Then, insert the following code where you would like to have it:

    <?php collapsCat(299723351) ?>
  36. robfelty says:

    Since this page is getting so ridiculously long, I am closing comments. Please post your bugs, questions and feature requests in the collapsing categories forum.



  37. Pingback: Firefly » Blog Archive » Firefly-Update

  38. Pingback: Meny i sidebar med innhold rangert alfabetisk -

  39. Pingback: Blog/Learning Log tidy up… | Phil Long - A photographer's journey

  40. Pingback: 'Collapsing Categories' plugin - width settingLet's Make This Easy!