Lets say we are displaying a few family trees. We are currently on the family tree top-page,and we need our list to look like this:
Family Trees
- The Smiths
- The Joneses
- The Does
When the user clicks the Smiths, we want the list to look like this:
The Smiths
- The Smiths
- Dave
- Steve
- Dolly
- The Joneses
- The Does
And when a user clicks on Steve, we want the list to also look like this:
Dave Smith
- The Smiths
- Dave
- Steve
- Dolly
- The Joneses
- The Does
So, we need to display a list of all subpages and siblings of the current page, as well as all siblings of every step in the hierarchy.
Any ideas?
What you write reminded me to some plugin / widget I know of. It’s related to Silo Web Design and the plugin is the Silo Widgets Plugin For WordPress. In SemPro you can make use of inline widgets to display something like that within posts.
This was a pretty decent plugin for displaying a flexible list of pages last time i tried it(no need for it myself)..
http://wordpress.org/extend/plugins/flexi-pages-widget/
If anything, you should be able to look to that plugin for some ideas and inspiration on how to tackle it..
I actually had to do this once. You can do it without a plugin and without javascript. You might have to tweak it a little to work exactly as you need it but it should give you the right idea; displaying parent pages and their children etc.
Here is the tutorial I used: http://www.svennerberg.com/2009/02/creating-a-submenu-in-wordpress/
Forget plugins, i had the same problem and plugins created a whole raft of mess and too many db calls.
This code will do the business for you – for ease of use, stick it in a content part and include it like so:
The problem is, you already know your children, and you know your parents. I tried using the wp-list-pages function , with echo set to false andincluding id’s but that got a little messy. This solution isnt perfect but it’s far cleaner than using a plugin or two.
In a nutshell – you want the absolute top parent id, then you want to get all the children of the current posts ancestors:
This code also adds the class ‘selected’ to the current post, and ‘parent’ to the current post parent within the list.
Hope that helps someone!