Fold Page Menus plug-in for WordPress
December 22nd, 2005Description
By default, WordPress displays all Pages in the Page menu. If your site has a lot of pages, this can start to look messy:

This plug-in removes the clutter, and creates menus which expand as you click on them. So, the example above looks like this:

If you click on This is a Main Page (no parent) you get:

and if you click on This is sub page one you get:

etc.
Installation
To install, simply download fold_page_menus.tgz into your wp-content/plugins directory and unzip it – it’s just a single file fold_page_menus.php. Install it through Site Admin -> Plugins as usual.
You then need to add it into your current theme. Edit the sidebar.php file and add fold_page_menus to the call to wp_list_pages.
For the WordPress default theme, this means changing this line:
<?php wp_list_pages('title_li=<h2>Pages'); ?></h2>
to this:
<?php wp_list_pages(fold_page_menus().'title_li=<h2>Pages'); ?></h2>
and that’s it.
How does it work?
wp_list_pages accepts an exclude parameter with a list of pages which should not be shown in the menu. This plug-in works out which pages to exclude and creates the necessary exclude= list.
Changelog
| Date | Version | Notes |
|---|---|---|
| 03-Mar-07 | v1.4 | Wordpress 2.1 broke the plug-in – this makes it work, but makes it incompatible with older versions |
| 23-Jan-06 | v1.3 | Update the documentation within the source code for the change of name |
| 08-Jan-06 | v1.2 | Minor fix to protect against the case when WordPress fails to pass an ID to the routine |
| 30-Dec-05 | v1.1 | Renamed to fold_page_menus (was jp_page_menu_condense) and now accepts a parameter specifying pages to exclude (like wp_list_pages) |
| 22-Dec-05 | v1.0 | Initial release of jp_page_menu_condense |

