Support » How-To and Troubleshooting » Is there a “If parent of parent post is” flag?
7 years, 7 months ago
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:
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?
Really didn’t know this function existed but a friend just emailed me it:
$ancestors = get_post_ancestors($post);
with 11 being switched for the grandparent id
6 years, 8 months ago
kudos…. needed this….