Hello,
I am trying to get breadcrumbs to display Home > Category > Post.
I’ve added the following code provided by support to the functions.php file in the child theme. Breadcrumbs are now displaying Home > Category, yet they are still not displaying the post name.
add_filter('x_breadcrumbs_data', 'post_parent_trail', 9999999, 2);
function post_parent_trail ($crumbs, $args) {
if ( is_singular('post') ) {
$category = get_the_category( get_the_ID() );
if ( count( $category ) > 0 ) {
$crumbs[1]['label'] = $category[0]->name;
$crumbs[1]['url'] = get_category_link( $category[0]->term_id );
unset($crumbs[2]); //to make sure category won't duplicate
}
}
return $crumbs;
}
How can I modify this code to include the Post Name at the end?
If you need, you can see what is happening at https://www.spiritualexcellence.com/blog/.
Thank you 