currently i am using this code to print a list of a parent-page and its children.
<?php
if($post->post_parent){
$children = wp_list_pages("title_li=&include=".$post->post_parent."&echo=0");
$children .= wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
} else {
$children = wp_list_pages("title_li=&include=".$post->ID."&echo=0");
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
}
if ($children) { ?>
<div class="meta-box">
<div class="nav-right">
<ul>
<?php echo $children; ?>
</ul>
</div>
</div>
<?php } ?>
Everything works fine when i am on a child page. It prints the title of the parent page and the titles of its children.
But when i am on a parent page it only prints the children and not the title of the parent page.
What i want to achieve:
When on parent page:
- Parent title (currently not showing)
- Child 1
- Child 2
- Child 3
When on child page:
- Parent title
- Child 1
- Child 2
- Child 3
Any help would be greatly appreciated
Mat
Your code works fine, you are missing a period in the ‘else’ rule