inspiredrichard
Member
Posted 1 year ago #
Hi there
I need to add a sidebar for navigation for only the immediate children of a page, not its grandchildren.
I found a piece of code which displays children and grandchildren:
<ul class="sidebar">
<?php wp_list_pages('child_of='.get_the_ID().'&title_li=<div class="sideTitle">'.__('Next Steps').'</div>');
?>
Any ideas on how to make it only display immediate children?
Cheers
Richard
[Please post code snippets between backticks or use the code button.]
inspiredrichard
Member
Posted 1 year ago #
Actually I just realised that I also need to show the siblings of the page I am on.
any chance of a hand with that too?
Cheers
:-)
You should be able to use the sub pages widget plugin for this http://wordpress.org/extend/plugins/subpages-widget/
Couldn't you just add '&depth=2' ?
inspiredrichard
Member
Posted 1 year ago #
Hi othellobloke
I tried that and it made no difference :-/
thanks anyway :-)
learncomputer
Member
Posted 5 months ago #
This will give you the list of immediate children of a given page.
$children = get_pages(array(
'child_of' => $your_page_ID,
'parent' => $your_page_ID,
'sort_order' => 'ASC',
'sort_column' => 'menu_order'
));
Also see http://codex.wordpress.org/Template_Tags/wp_list_pages#List_parent_Page_and_all_descendant_Pages for additional examples.