This snippet is from a book project – the book title needed to be shown on all subsequent chapters, unless it was the main book page. Here’s the snippet that does it:
<?php echo empty( $post->post_parent ) ? get_the_title( $post->ID ) : get_the_title( $post->post_parent ); ?>
[…] snippet is from the same book project as this snippet that gets the title of the parent page. It allows us to show the same header image on all subsequent chapters of a book (child […]