Display name of parent page in child page
-
I’m trying to get name of parent page in child page, but it doesn’t work as I wanted to when page got a few parent pages, like: catalog > pictures > pine photo. It display as parent page “catalog” instead of “pictures”. Here’s the code:
<?php if ( 0 == $post->post_parent ) { the_title(); } else { $parents = get_post_ancestors( $post->ID ); echo apply_filters( "the_title", get_the_title( end ( $parents ) ) ); } ?>
Any ideas how to do it? Thanks
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Display name of parent page in child page’ is closed to new replies.