Oaktree is a small plugin for WordPress that generates an automatic XHTML navigation structure (nested unordered lists) from your pages. There might be other similar plugins around, but feel free to give it a try. The plugin has functions for writing navigation and navigation crumbs.
This version is tested with WP 2.0.x and PHP5. I’ve used an unpolished version since 1.5.x days so it should work too. The question is who would like to use 1.5. when 2.0 offers much more :) Oh and there is no warranty or support.
UPDATE: The database in WordPress 2.1. has changed. You need to change the SQL select to search for post_type instead of post_status:
- AND post_status = ’static’
+ AND post_type = ‘page’
Thanks to Wil Stuckey for the heads up.
Another example… let’s exclude pages with ID 4 and 5:
< ?php global $oaktree;
// exclude pages 4 and 5
$noShow = array(4,5);
$oaktree->writeNavigation(false,”,$noShow); ?>The navigation tree is yours to modify at runtime, so do a print_r() $oaktree and tweak on. This is not rocket science:
oaktree Object
(
[tree] => Array
(
[8] => Array
(
[id] => 8
[title] => Desktop Wallpapers
[path] => http://janit.iki.fi/desktops/
[active] =>
)
[9] => Array
(
[id] => 9
[title] => Apache benchmarking with Wordpress, eAccelerator, WP-Cache, mod_rewrite
[path] => http://janit.iki.fi/wp-bench/
[active] =>
)
[11] => Array
(
[id] => 11
[title] => Apple iBook (Dual USB) hinge problem fix
[path] => http://janit.iki.fi/ibook-hinge/
[active] =>
)
[12] => Array
(
[id] => 12
[title] => Oaktree WordPress navigation plugin
[path] => http://janit.iki.fi/oaktree/
[active] =>
)
)
[wp_filter_id] => 4
)
And XHTML+CSS has some great tricks for this stuff? you should get it:
<div id="naviContainer">
<?php global $oaktree; $oaktree->writeNavigation(); ?>
</div>
<style type="text/css">
#naviContainer * {
display:block;
margin:0;
padding:0;
}
#naviContainer a {
text-decoration:none;
padding:5px;
}
#naviContainer a:hover {
text-decoration:underline;
}
#naviContainer a.selected {
font-weight:bold;
}
</style>Hope this is useful for someone else too.