• Hey, in the side bar of my children posts I want to have a link that takes the visitor back to the parent page. This is easy on child pages with one parent as I can simply insert:

    <?php if($post->post_parent=="1025"){?>

    However as soon as I get child pages more than one level deep such as:

    Fish > Tropical Fish > Amazon Fish

    Then the above code no longer works because post_parent id is now Tropical Fish rather than Fish.

    How would I get this to work?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Carbon-12

    (@carbon-12)

    Really didn’t know this function existed but a friend just emailed me it:

    $ancestors = get_post_ancestors($post);
    if (in_array(11,$ancestors)){
    ...
    }

    with 11 being switched for the grandparent id

    kudos…. needed this….

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Is there a “If parent of parent post is” flag?’ is closed to new replies.