I have following page structure:
- Main page (id 5)
- Subpage 1
- children page
- children page
- Subpage 2
- children page
- children page
- Subpage 1
I use this code for displaying my sidebar menu:
<?php wp_list_pages('child_of=5&title_li=&link_before=<span>&link_after=</span>'); ?>
This code displays only a list. I would need to display
- when on the main page, display only subpages
- when on the subpage, display subpages and children pages of the subpage I’m currently on
- when on the children page, display the display subpages and children pages of the parent subpage I’m currently on
Any idea how to do this?
Thanks for help
Use Depth to handle what you want it to show
Reference: http://codex.wordpress.org/Function_Reference/wp_list_pages
You could try to use this Hierarchical Pages Widget. I’m not sure if it supports exactly what you want, but I used it on one of my projects and it worked great.
This widget will:
I found a working code, works like a charm for me: