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:

// 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
    //do something
    //do something else

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!