Advanced Subpages Menu for WordPress
by zartgesotten on Juni 26, 2009
Someday you might want to list subpages of the current page in your sidebar. But what will happen if you klick on one of those listed subpages? To make sure that you’ll not only have the list when you’re on the parent page but also when you are on one of its subpages (The list then shows siblings, of course) , you can put this code in your sidebar.php.
<?php
global $wp_query;
if( empty($wp_query->post->post_parent) )
{
$parent = $wp_query->post->ID;
}
else
{
$parent = $wp_query->post->post_parent;
} ?>
<?php if(wp_list_pages("title_li=&child_of=$parent&echo=0" )): ?>
<div id="submenu">
<ul>
<?php wp_list_pages("title_li=&child_of=$parent" ); ?>
</ul>
</div>
<?php endif; ?>
Leave your comment