Collapsing Pages

Please deactivate before upgrading, then re-activate the plugin.

The Collapsing Pages plugin creates a list of all pages and sub-pages, which can be expanded and collapsed dynamically, as you can see in the sidebar on this page. The main function is as a widget, but there is also an option to use it as a drop-down horizontal menu for basic page navigation, if you are using wordpress as a cms, as in the screenshot below:

Collapsing Pages screenshot

Note that the dropdown functionality has been removed in version 0.3, and will be made into a separate plugin in the near future.

The plugin is hosted on the official wordpress repository at:

If you have any questions, bug reports, or feature requests, please go to the forum

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:

69 Replies to “Collapsing Pages”

  1. Hello, Rob

    First I hope you understand what I wrote because I’m using the google translator.
    Downloaded plugin CollapsingPages [WordPress 2.5.1] and liked much because I have several pages with sub-pages.
    But the code completely changes the look of my sidebar. [my theme is not widgets].
    The text is very large, the background is white [my theme is black].
    Placed in style.css the tips to change the color of the links. It worked [took to find out which should place before the #].
    I made several attempts to try to change the look, but do not understand, PHP, or CSS, I was a failure.
    Maybe you can help?
    A hug.

  2. Hi

    How can I get rid of the triangle and make the parent title the collapse function?

    Thanks for your great work.

  3. hello, i was desperately looking for a plugin that would allow me to have collapsing archives and tried installing this according to the instructions… but it was quite impossible and had so many errors, i’m not sure what went wrong. :( maybe i need to ask for professional help for this!

  4. My installation works when I first click to expand a parent page, but at that point no down arrow (or minus sign) appears and it can not be re-collapsed. Is this a bug?

    Also, I too would be curious to know if there is a way to make the parent title itself expand and collapse the sub-pages instead of linking to its own page…


  5. Hi,

    Issue with collapsing pages plugin. I have installed the plugin successfully on my localhost but when uploading to my live host server the collapsing pages menu is not displaying. Other collapsing plugins, such as collapsing categories work fine, but not collapsing pages.

    Help in this regard is much appreciated!!



  6. This plugin is exactly what I am looking for, however, I get three errors when I try to include a third level of pages. (eg. Page > Sub Page > Sub Sub Page) The error occurs even when I change the option for displaying pages at a only a higher level.

    I will gladly provide you with a copy of the errors (missing arguments and wrong data types).

  7. bug:
    Warning: Missing argument 7 for getSubPage(), called in /wp/wp-content/plugins/collapsing-pages/collapsPageList.php on line 59 and defined in /wp/wp-content/plugins/collapsing-pages/collapsPageList.php on line 29
    thank you for your help

  8. i am currently using wordpress 2.6.3
    i downloaded the collapsing pages plugin and
    the error below is showing if Page>Subpage>subpage is selected.
    is there a way to fix this?
    please let me know. thank you very much.

    Warning: Missing argument 7 for getSubPage(), called in C:\xampp\htdocs\wordpress\wordpress\wp-content\plugins\collapsing-pages\collapsPageList.php on line 59 and defined in C:\xampp\htdocs\wordpress\wordpress\wp-content\plugins\collapsing-pages\collapsPageList.php on line 29

  9. Warning: Missing argument 7 for getSubPage()

    Got the same error as “faus” gets. Don’t you know what’s, wrong?

  10. Sry, did not saw your last post. Anyway I have instaled the 2.4 version and now getting:
    Warning: in_array() []: Wrong datatype for second argument in

  11. Sry, there it comes:

    Warning: in_array() []: Wrong datatype for second argument in /home/users/username/ on line 63

  12. @Jup,

    Sorry for the delay. I fixed it in version 0.2.5 a few days ago, and figured you would see that. But I just now realized that wordpress was still listing 0.2.3 as the stable version. That should be fixed now.


  13. hi,
    first of all thanks for your plugin and time given to community.
    i’ve put my hands on this plugin and was a little sad to see that the plugin didnt autoexpand currentpage.

    first i tried to guess how to modify the code to make it detect the current page, then auto-expand parent pages and auto-close others etc.. it was quite complicated, in fact
    so i looked into wp_list_pages() and found that it has current_page_item, current_page_ancestor style attributes that the current list_pages() plugin function doesnt have.

    here is a replacement for the list_pages function that i think i have to share with you (works only if you need nested menu) :

    function list_pages() {
    if (get_option('collapsPageExpand')==1) {
    $collapseLink = "$collapse ";
    $expandLink = "$expand ";

    $out = wp_list_pages(array('echo'=>false,'title_li'=>null));
    $out = preg_replace('/(]*current_page_[^>]*>]*>[^<]*[^<]*)/', '\1'.$collapseLink.'', $out);
    $out = preg_replace('/(]*((?!current_page_)[^>])*>
    ]*>[^<]*[^<]*)/', '\1'.$expandLink."", $out);

    echo ''.$out.'';

    it is only regexp (btw ugly regexp quickly coded, if you see a way to improve it it’s cool) but seems to work as before and also adds autoexpand for currentPage ! \o/
    i’ve never coded wp plugins before but this works on my in-progress blog, so i dont know if i am missing something or doing something wrong..

    hope it helps


  14. Hello,
    I have problem with this widget.
    I added this to my site but it takes all width of site not only width of sitebar, so it cover my posts.

    PS: Sorry for my bad english ;)

  15. Rob, I send you mail with link to my page. I found that this is foult of theme which I,m using and I have to repare it, but I have no idea how ;p

  16. Hi

    Thanks for your widget. I am currently using it for a website I didn’t put online yet.

    I’m sorry but I have 3 questions. I know, it’s a lot.

    1) It works for sidebars but I don’t know how to use it for a header as in your example with the button “about”.

    Did you explain somewhere how to use collapsing-pages on a header ?

    2) On my website, for the sidebars, I use images for + and -. But sometimes, the browser can’t open the images so it is written “expand” or “collapse” instead of having a + and -. Is there something I can do for it ?

    3) Is it possible to configure your widget in order that anytime I would click on a page or on an article, all the sub-pages would collapse?
    I ask this because, in my case, I have many pages linked to parent pages. If it could collapse anytime I go somewhere in my website, the sidebar would be clearer, cleaner.

    Thank you and sorry for all my questions.


  17. Hi Robert

    I am really sorry but I have a 4th question.

    I tried to exclude 4 pages but it worked only with 2 of them. I checked many times if the spelling of the page title was exactly the same than the spelling I put in exclusion box. But it finally doesn’t work.

    Is it possible to exclude page id or menu order ?

    Thank you, Merry Christmas

  18. @Raphael,

    Sorry for the slow response. I have been busy with family for the holidays.
    I will try to answer your questions –
    1. Header – I actually removed this functionality in 0.3, and am working on making that a separate plugin, since I didn’t think it was that related. However, if you think it is related, I could try to add it back in. In any case, using it both as a widget, and as a drop down like in your header is not possible at the moment. You can only do one or the other (and to use it in your header, you would have to use a previous version (0.2.3 I think).

    2. I am not sure why the images are not showing up. What browser are you using?

    3. Many people asked for the exact opposite of this request. That is, people requested that if they expanded the parent page “foo”, that “foo” would be expanded if they navigated to a different page. This is the current functionality. I could make this into an option in the future.

    4. Do your pages have any special characters in them? Right now the exclusions work with either the title or the slug.

    If you send me a link to your site, I might be able to help more.

    Merry Christmas to you too.


  19. Greetz,

    I’m back with a problem again. :( Your latest version 0.3 is acting weird in WP 2.7. When I add it into sidebar list and save it your widget dissapear from the list. So it can’t be enabled. Is it some bug or am I doing something wrong?

    Version 0.25 was working fine.


  20. Just a heads-up, I love the plugin, but after this new upgrade, to 2.7, the widget doesn’t show any of my categories in it. I haven’t changed my settings from the previous install, nor have I changed anything about my theme. Any ideas on why my categories wouldn’t show up in your widget, but just fine in the normal Categories widget?

  21. @Jup and John,

    Please follow the installation instructions in the readme.txt file. There is a known bug with this plugin and WP 2.7. A workaround is detailed there. Hopefully I will have time to do a real fix soon.


  22. I am using WordPress 2.7 and I am having a unique issue. I can get the plugin to show on my pages, but there are no pages listed. I have tried every combination of settings and still nothing. I have examined the source code and it shows up as:

  23. Pages

  24. Any idea what could be wrong. I prefer not to give out the web address here as the site is still under construction, but I am willing to via email. Thank you for your help.

  25. Hello there Rob,

    Quick query about the adding of ‘self’ class to the current page – this only appears to work on top level pages, so that when I navigate to a sub-page, no ‘self’ class gets assigned, and the current page is unstylable (and still linked). Is this intentional? Any way round it? Would be fantastic to be able to style the current sub-pages in the same way as top level pages.

    Many thanks!

  26. @Simon,

    Thanks for pointing that out. I think I had been working on that feature, and then never got it totally figured out. I added a self tag to subpages now too in 0.3.2


  27. Wonderful, thanks a million, Rob. I noticed that the plugin doesn’t play well with Lightbox, by the way, as they both call up different versions of prototype.js (well, the same version, but in different locations). Commenting out the prototype call in the Lightbox seems to do the trick, and although I’m occasionally getting ‘nv is null’ errors in my Firefox error console, they don’t appear to stop stuff from working.

    Thanks for all your work.

  28. @Simon,

    WordPress has a function called wp_enqueue_script which ensures that only one copy of a javascript file is loaded, and it checks the version. However, if the lightbox plugin is not using this to load the prototype library, then you will get problems. You might want to ask the author of the lightbox plugin you are using.


  29. Hi,

    I’m using collapsing pages 0.3.2 with WP 2.7.
    I’ve noticed that when “Animate collapsing and expanding” is selected, my pages just won’t expand – only the plus sign will change to a minus (that way, I can only access my top level pages).
    On another note, when I’m browsing a page with subpages, not only the menu entry for the current page is highlighted (=bold), but also its subpages (and, if present, their subpages) are. I think that’s not really desirable – just the current page is enough highlighting.

    Other than that, great plugin.

  30. @Bernhard, this is probably a conflict with another javascript library being loaded by another plugin. Collapsing Pages uses scriptaculous, and is loaded correctly using wp_enqueue_script. You might check your other plugins. I did not see the plugin being used on your page. Is this a different site you’re referring to?


  31. Okay, I’ve identified the culprit: it was the slimbox plugin (and yes, this is about a site that hasn’t gone online yet).

    On the other issue, I’ve just updated the collapsing pages plugin, but now there’s no bold highlighting at all. Instead, for menus consisting of more than just one nested hierarchy level, the word “foo” is displayed in front of the minus signifying an expanded menu list (I’m using the plain html +/- style) when browsing the corresponding page or any page below that page’s hierarchy level. I’m observing this behavior for any page except for the top hierarchy.

    Last but not least, there seem to be some oddities with some themes where the collapsing menu list bullets interfere with the theme ones (ie both are displayed, eg in case of the Brownbound theme). I think this isn’t really desirable, but I’m not sure what would be better as the theme of course does not provide collapse/expand icons. One possible way would be suppressing the theme’s bullets altogether for collapsing page hierarchies.

  32. Bernhard – I removed the debugging info in 0.3.4. To get the bold highlighting, deactivate, reactivate, then click on “restore original style” in the settings panel.

    For other styling issues, this can all be addressed with css in the settings panel. Just set list-style-type to none for any <li> that you don’t want to have a bullet. The default css style does this for the default wordpress style. You might need to change #sidebar to something else.


  33. Bernhard, love the plugin… I noticed a few things while trying to use this on a site I’m building for a friend. I don’t think that the “include posts and pages” checkbox in the widget options needs to be there anymore in 0.3.4 since this is only for pages. Also, though the debugging is deprecated, the checkbox option is still there also in the widget options. In the widget options, under the auto-expand option it states “category” instead of “page(s)” – a carryover from it’s relative. Lastly, though I am inserting the correct pageid in both the exclude and autoexpand options, neither works (the pages are neither excluded nor autoexpanded). I think that’s it. Love your work here… been looking for something like this for a long time.


  34. Scott,

    Thanks for pointing out the mistake of “category” instead of “parent page”. I will change that. You don’t want to use page ids though. Enter the page title or slug. For some reason people keep trying to use the id, which seems much less user-friendly to me. How can I make this more obvious?

    Also, what do you mean that the debug option is deprecated? If you are having trouble, it provides very useful information (both for you and for me if you ask a question).


  35. Rob (sorry I got the name wrong, reading them all mixed up my mind)

    Thanks for the reply… it could be my mistake on the deprecation, I assumed that by the post above that says, “I removed the debugging info in 0.3.4” – as for your question, maybe including “(page slug)” in the option line might help. I assumed it was pageid because I’ve used so many other addons that use it. Your way is much much much better. Again, I can’t convey how much I love this plugin. Thanks!


  36. Wanted to let you know that the exclude page works great with the slug, but autoexpand did not work for me using the Title or the slug. You can see it here


  37. Scott,

    Glad that is working. The cookies can be confusing there. But it is the only way I could think of making them stick for different visitors.

    Also, I was referring to a stray “foo” I had left in the code that Bernhard pointed out, not the debugging option. That wasn’t very clear.

    I will work on making the exclude and expand options more transparent.


  38. Hi,

    I’ve now tried collapsing pages together with the qtranslate internationalization plugin and found that page titles aren’t displayed properly due to lack of l10n functions. I’m attaching what seems to solve the issue:

    --- collapsPageList.php 2009-01-21 20:37:24.000000000 +0100
    +++ collapsPageList_modified.php 2009-01-28 14:57:22.000000000 +0100
    @@ -92,7 +92,7 @@
    $link2 = " $link2 .= '>';
    - $link2 .= $page2->post_title. "
    + $link2 .= __($page2->post_title) . "";
    $subPageLinks.= $link2 ;
    if (!in_array($page2->id, $parents)) {
    @@ -227,15 +227,15 @@
    $link = " if ( empty($page->page_description) ) {
    if( $showPostCount=='yes') {
    - $link .= 'title="'. sprintf(__("View all posts filed under %s"), wp_specialchars($page->post_title)) . '"';
    + $link .= 'title="'. sprintf(__("View all posts filed under %s"), wp_specialchars(__($page->post_title))) . '"';
    } else {
    - $link .= "title='View all subpages'";
    + $link .= 'title="' . __("View all subpages") . '"';
    } else {
    $link .= 'title="' . wp_specialchars(apply_filters('page_description',$page->page_description,$page)) . '"';
    $link .= '>';
    - $link .= $page->post_title.'
    + $link .= __($page->post_title) . '';

    // TODO not sure why we are checking for this at all TODO

  39. Bernhard,

    Thanks very much for the code. Internationalization has been on my mental todo list for a long time. I will incorporate these changes soon.


Comments are closed.