Displaying Parent name in sidebar
-
I’ve set up my template to display links to the Child Pages of a Parent in the sidebar – but only when you are viewing that Parent. At the moment I’m using the following code:
<ul class="block"> <?php if($post->post_parent) $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"; else $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0"); if ($children) { ?> <ul> <?php echo $children; ?> </ul> <?php } ?> </ul>
And everything is working fine…
But, I would like to display the title of the Parent page above these links to the Children…
I’m new to PHP and I’m still trying to get my head around it…I understand enough to know that the top part of the PHP code is determining whether or not the page is a child, and that the part on the bottom calls the function to either display the child links, or not. I’m just unclear where to add a snippet of code to basically say:
IF child page THEN display PARENT-TITLE above child links in h2
Any help would be greatly appreciated!
- The topic ‘Displaying Parent name in sidebar’ is closed to new replies.