Skip to content

Instantly share code, notes, and snippets.

@jamiemitchell
Last active December 16, 2015 12:08
Show Gist options
  • Save jamiemitchell/5432045 to your computer and use it in GitHub Desktop.
Save jamiemitchell/5432045 to your computer and use it in GitHub Desktop.
Get Title for the Top Level Parent Page Still working on this
<?php
function get_top_level_parent_title() {
global $post;
if ( empty($post->post_parent) )
{ the_title(); }
else {
$ancestors = get_post_ancestors($post->ID);
end($ancestors);
echo get_the_title($ancestors[0]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment