Last active
December 16, 2015 12:08
-
-
Save jamiemitchell/5432045 to your computer and use it in GitHub Desktop.
Get Title for the Top Level Parent Page Still working on this
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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