I want outside assistance with wordpress. The concept is create multioptional navigation in sidebar. Hierarchy is appears like this:
<ul>
<li>First Page
<ul>
<li>First SubPage</li>
<li>Second SubPage
<ul>
<li>First Sub-SubPage</li>
<li>Second Sub-SubPage</li>
<li>Third Sub-SubPage</li>
</ul>
</li>
</ul>
</li>
<li>Second Page</li>
<li>Third Page
<ul>
<li>First SubPage</li>
<li>Second SubPage
<ul>
<li>First Sub-SubPage</li>
<li>Second Sub-SubPage</li>
<li>Third Sub-SubPage</li>
</ul>
</li>
</ul>
</li>
</ul>
However i take some features. After i on First Page, i would like see only subpages of the page, not every pages in menu.
The way i can resolve this issue?
Thanks
Take advantage from the function get_pages
http://codex.wordpress.org/Function_Reference/get_pages
You should use the next function. Refer to it as within the sidebar with $page_id as <current page id>
.
<?php
function show_child_list($page_id) {
$child_pages = get_pages( array( 'child_of' => $page_id, 'sort_column' => 'menu_order', 'sort_order' => 'ASC', 'parent' => $page_id) );
echo '<ul>';
foreach($child_pages as $child) {
echo '<li>'.$child->post_title.'</li>';
show_child_list($child->ID);
}
echo '</ul>';
}
Update 1:
Added 'parent' => $page_id
attribute in third line, so only first level child are came back.