Ready to get started?Download WordPress


Get parent page ID (or slug) (3 posts)

  1. grosbouff
    Posted 7 years ago #

    Hello, I've read that it is possible to retrieve the link to the parent page with
    echo '<a href="'.get_permalink($post->post_parent).'">'.get_the_title($post->post_parent).'</a>';

    But is it possible to retrive the parent page ID or slug ?

    Thanks !

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    Sure. You already know how: $post->post_parent is the parent's ID number.

  3. Anonymous
    Posted 6 years ago #

    Here is the parent page ID

    Here is the Parent page Title
    $post_id_7 = get_post($parentpageid);
    $parentpagetitle = $post_id_7->post_title;

    Here is the parent page link

Topic Closed

This topic has been closed to new replies.

About this Topic