Thanks @alexander! Now I see what was wrong
I wanted to also show the category in the breadcrumbs, so I had included the snippet shared by support in this thread.
However, that seems to be what caused the issue. That snippet had get_post_permalink
in there for the post’s URL. When I switched that to get_permalink
, it all started working as expected. So I think I’m squared away now!
BTW, here’s the full snippet in case there’s anything you’d suggest changing about it.
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[] = array(
'type' => 'category',
'url' => get_category_link( $category[0]->term_id ),
'label' => $category[0]->name,
);
$crumbs[] = array(
'type' => 'post',
'url' => get_permalink( get_the_ID() ),
'label' => get_the_title(get_the_ID()),
);
unset($crumbs[2]); //to make sure category won't duplicate
}
}
return $crumbs;
}