Pages Menu Hack – HELP NEEDED PLEASE!
-
Hi!
I’ve added this piece of code into the content of page.php to display child pages of the particular page.
<?php $children = wp_list_pages('title_li=&child_of='.$post->ID.'&depth=1'.'&echo=0'); if ($children) { ?> <div id="singlemenu"> <div id="singlepagesmenu"> <ul class="menu"> <?php echo $children; ?> </ul> </div> <!--END: pagesmenu--> </div> <!--END: menu--> <?php } ?>
It works perfectly, always displaying the next children of the particular active page. For example, when the About page is active, it shows the two child pages of the About page, eg About 1-1 and About 1-2. When I click on About 1-1, it displays that page’s children, eg About 1-1-1, About 1-1-2 and About 1-1-3.
As soon as the current page is the last child (eg About 1-1-1) the menu disappears, which is also what I intended.
NOW FOR THE TRICKY PART:
I want to display the parent pages as soon as I reach the first child page. I’ve tried this:
<?php $parent = wp_list_pages('title_li=&parent_of='.$post->ID.'&depth=1'.'&echo=0'); if ($parent) { ?> <div id="singlemenu"> <div id="singlepagesmenu"> <ul class="menu"> <?php echo $parent; ?> </ul> </div> <!--END: pagesmenu--> </div> <!--END: menu--> <?php } ?>
The problem with that is that the MAIN MENU (eg HOME, ABOUT, BLOG, etc) is then also displayed. I don’t want that! What do I need to do to make the parent pages show up in a menu, but to exclude the top-order menu from showing up?
I would really appreciate some help with this!
Thank you!
BTW: This piece of code comes from WP Recipes… Great source!
- The topic ‘Pages Menu Hack – HELP NEEDED PLEASE!’ is closed to new replies.