Hi
When I'm browsing a topic in my forum (bbpress) I notice that the breadcrumb only displays the immediate parent of the topic. However, I was expecting to see the complete set of parents of the topic: the topic is under Forum_B, and Forum_B is a forum under Forum_A:
- Expected: Home >> Forum_A >> Forum_B >> Topic_Title
- Actual: Home >> Forum_B >> Topic_Title
Tracking the code, I found that in the YOAST file 'class-breadcrumbs.php' , the call to isset( $post->ancestors ) is returning false.
However, if instead of using $post->ancestors I use get_post_ancestors($post->ID) it works like a charm.
Not sure how to fix it other than modifying class-breadcrumbs.php .
Any idea why $post->ancestors is NOT set? Or any filter/action that I could write to avoid having to modify class-breadcrumbs.php ?
Thanks!
Juan
OLD CODE:
if ( isset( $post->ancestors ) ) {
if ( is_array( $post->ancestors ) )
$ancestors = array_values( $post->ancestors );
else
$ancestors = array( $post->ancestors );
} else {
$ancestors = array( $post->post_parent );
}
NEW CODE:
$post_ancestors = get_post_ancestors($post->ID);
if ( isset( $post_ancestors ) ) {
if ( is_array( $post_ancestors ) )
$ancestors = array_values( $post_ancestors );
else
$ancestors = array( $post_ancestors );
} else {
$ancestors = array( $post->post_parent );
}