get\\u post\\u祖先()按层次结构返回所有祖先。由于您只想在第4个帖子页面上显示第2级帖子标题,您可以执行以下操作-
global $post;
$parents = get_post_ancestors( get_the_ID() );
if( count($parents) == 4 ){
// ancestor1 = 1st parent, ancestor2 = second.
echo get_the_title($parents[\'1\']); // index starts from 0, 1 = 2nd item
}