WordPress: get post_parent title
It looks like you've already got the ID of the parent post, so you can just use this:
<?php $parent_post_id = 6; $parent_post = get_post($parent_post_id); $parent_post_title = $parent_post->post_title; echo $parent_post_title;?>
(Insert your parent post id at $parent_post_id)
This is the clean and nice code you need:
It is also save to use when there is more than one parent hierarchy level.
<?php $current = $post->ID; $parent = $post->post_parent; $grandparent_get = get_post($parent); $grandparent = $grandparent_get->post_parent; ?> <?php if ($root_parent = get_the_title($grandparent) !== $root_parent = get_the_title($current)) {echo get_the_title($grandparent); }else {echo get_the_title($parent); }?>