I've been looking for a solution to my problem for some time now, and I can't seem to find one.
I have created a submenu using the following code from the Codex:
<?php
if($post->post_parent) {
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
$titlenamer = get_the_title($post->post_parent);
}
else {
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
$titlenamer = get_the_title($post->ID);
}
if ($children) { ?>
<h2> <?php echo $titlenamer; ?> </h2>
<ul>
<?php echo $children; ?>
</ul>
<?php } ?>
This worked fine until I added siblings to a child menu.
I want the menu to work like this:
- Main menu
- Submenu (Children)
- Siblings
But using the before code above I get this (as show in this image http://www.inlusiondesign.dk/images/stories/wp_list_pages-problem.png):
- Main menu
- Submenu (Children)
- Siblings
If I where to click e.g. "Test 1" everything is fine again - I suppose this is because it hasn't got any children.
I have tried using "depth=2" in various places, but that didn't work.
Thanks in advance.