使用get\\u post\\u祖先():
// get page ancestors
$parents = get_post_ancestors( $post->ID );
// id of parent page you want to find
$parent_id = 123;
// check of $parent_id
if ( $post->ID == $parent_id || in_array( $parent_id, $parents ) ) {
echo \'<a href="#">Link</a>\';
}