Skip to main content
added 12 characters in body
Source Link
kaiser
  • 50.8k
  • 27
  • 150
  • 244

Found this way:

if ( 0 == $post->post_parent == 0) {
    the_title();
} else {
    $parents = get_post_ancestors( $post->ID );
    echo apply_filters( "the_title", get_the_title( end ( $parents ) ) );
}

Anyone got a better way please answer.

Found this way:

if($post->post_parent == 0) {
    the_title();
} else {
    $parents = get_post_ancestors($post->ID);
    echo apply_filters("the_title", get_the_title(end($parents)));
}

Anyone got a better way please answer.

Found this way:

if ( 0 == $post->post_parent ) {
    the_title();
} else {
    $parents = get_post_ancestors( $post->ID );
    echo apply_filters( "the_title", get_the_title( end ( $parents ) ) );
}

Anyone got a better way please answer.

Source Link
Scott
  • 12.3k
  • 15
  • 68
  • 99

Found this way:

if($post->post_parent == 0) {
    the_title();
} else {
    $parents = get_post_ancestors($post->ID);
    echo apply_filters("the_title", get_the_title(end($parents)));
}

Anyone got a better way please answer.