Get parent page title; If parent get current title

echo empty( $post->post_parent ) ? get_the_title( $post->ID ) : get_the_title( $post->post_parent );

Sourced here.

Updated: November 2, 2016

global $post;
$page = $post->ID;

if ($post->post_parent) {

   $page = $post->post_parent;
   
   echo get_the_title($page);

} else {

	the_title(); 

}

 

Leave a Reply

katherine as a flat graphic icon

About Me

I’m an African / Ojibwe First Nations Web Developer living in Winnipeg, Manitoba.

Visit the Tips and Blog to see what I’m working on.