$ancestors = get_post_ancestors( $post->ID );
これで直近の親だけではなく、最深の先祖までの投稿IDを配列で取得できます。
<title>の場合なら、
$title = strip_tags ( get_the_title() ) . ' | ';
foreach ( $ancestors as $ancestor ) {
$title .= strip_tags ( get_the_title( $ancestor ) ) . ' | ';
}
$title .= get_bloginfo( 'name' );
パンくずリスト(トピックパスっていった方がかっこいい?)の場合は、配列を逆転させて、
$ancestors = array_reverse ( $ancestors );
$pankuzu = '';
foreach ( $ancestors as $ancestor ) {
$pankuzu .= '<li><a href="' . get_permalink( $ancestor ) . '">' . get_the_title( $ancestor ) . "</a> ></li>\n";
}
$pankuzu .= '<li>' . get_the_title() . "</li>\n";
みたいな感じでしょうか。
