WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can i get the name of a page's parent?
I can only get it's id.

        $page = get_queried_object();
        $pageparent = $page->post_parent;
share|improve this question
Can you be clearer please ... a post is related to a category or tag posts are not linked to pages (pages are static and usually dont have categories or tags) – Damien Aug 25 '12 at 8:46
@damien, it's a page, hierarchical one. i've edited the question, thanks – NestedWeb Aug 25 '12 at 8:49
ok ill edit the question ... but have you checked the related results -----> or read up on get_pages codex.wordpress.org/Function_Reference/get_page – Damien Aug 25 '12 at 8:53
i just tried with get_page, even then i can only get direct parent's and all ancestors 'id'. – NestedWeb Aug 25 '12 at 9:00
up vote 0 down vote accepted

Once you've got the id of a post or page, use get_the_title($id) to get the page title (which is what I assume you mean by name)

Codex Reference

share|improve this answer
Thank you, never though there's such a function. – NestedWeb Aug 25 '12 at 13:27

Note that get_queried_object will only work on pages with a single post (or page) on them. For example, if you were trying to find a parent of a post on a category archive page, get_queried_object would return the category, not the current post.

So, using the following would work in more circumstances:

global $post;
$parent_title = get_the_title( $post->post_parent );
share|improve this answer
global $wpdb;
$page_id = YOUR_PAGE_ID; //your page id here.
$parent_page_id = $wpdb->get_var( $wpdb->prepare( 
    SELECT post_parent 
    FROM $wpdb->posts 
    WHERE ID=$page_id;
) );
$parent_page_title = get_the_title($parent_page_id);
echo $parent_page_title; //this will print parent page title.



share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.