Friday, February 10, 2012

How to display the list of child pages on the parent page.

Displays a list of WordPress pages as links. It is often used to customize the sidebar or header.

We can display the list of child pages on the parent page.

Displays the sub-pages of a single Page only;
uses the ID for a Page as the value.

if($post->post_parent)
{
$parent_title = get_the_title($post->post_parent);
echo "<h3 class='product1-title'>".$parent_title.":</h3>";
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
}
else
{
$parent_title = get_the_title($post->post_parent);
echo "<h3 class='product1-title'>".$parent_title.":</h3>";
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
}
if ($children) { ?>
<ul id="subnav">
<?php echo $children; ?>
</ul>
<?php }?>

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.