WordPress Menu Question
Here's a sample of the menu:
HOME
BLOG
BASICS
- Sub Menu 1
- Sub Menu 2
- Sub Menu 3
EDUCATION
WORKSHOPS
- Sub Menu 1
- Sub Menu 2
- Sub Menu 3
ORDER NOW
When a page without children is active it should display as:
HOME
BLOG
BASICS
EDUCATION
WORKSHOPS
ORDER NOW
I've got that setup without any troubles.
When a page with a child is active (in this case 'BASICS'), I want the menu to show as:
HOME
BLOG
BASICS
- Sub Menu 1
- Sub Menu 2
- Sub Menu 3
EDUCATION
WORKSHOPS
ORDER NOW
...where only the active page's children are displayed. With my current setup, only the children show on the parent page (no other menu items are displayed).
I could write a workaround manually, but am looking for a dynamic snippet. Here's what I currently have:
<ul>
<?php
$output = wp_list_pages('echo=0&depth=1&title_li=' );
if (is_page()) {
$page = $post->ID;
if ($post->post_parent) {
$page = $post->post_parent;
}
$children=wp_list_pages('echo=0&child_of=' . $page . '&title_li=');
if ($children) {
$output = wp_list_pages('echo=0&child_of=' . $page . '&title_li=');
}
}
echo $output;
?>
</ul>
Thanks!