Get parent page name

Get the parent page name to use in menus etc, or to use in a conditional tag. To use the snippet, just paste it where you want to display the parent pages name.

Code Snippet:

<?php
// get the page name
$parent_title = get_the_title($post->post_parent);

// display page name
echo $parent_title;

// Use as a conditional tag
// If pagent page is named Archives
if($parent_title=="Archives"):
    //do something
else:
    //do something else
endif;
?>

Posted in Pages, Conditional