WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. grosbouff
    Member
    Posted 6 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 6 years ago #

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

  3. Anonymous
    Unregistered
    Posted 5 years ago #

    Here is the parent page ID
    $post->post_parent

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

    Here is the parent page link
    get_permalink($parentpageid)

Topic Closed

This topic has been closed to new replies.

About this Topic