Hi Manny @mannyo, thank you for your feedback.
Although I don’t recommend showing all categories on the breadcrumb, you can get it done by using the filter ‘breadcrumb_block_get_items’. Here is the sample code:
add_filter( 'breadcrumb_block_get_items', function($items, $breadcrumb_instance) {
if ( is_singular('post') || is_singular('page') ) {
// Global post.
global $post;
// Overide the all breadcrumb items.
// Reset.
$breadcrumb_instance->reset();
// Home link.
$breadcrumb_instance->add_crumbs_front_page();
// Get all categories.
$categories = get_the_category( $post );
if ( ! empty( $categories ) ) {
foreach( $categories as $category ) {
$breadcrumb_instance->add_item( $category->name, get_category_link( $category->term_id ) );
}
}
// Current post/page.
$breadcrumb_instance->add_item( get_the_title( $post ), get_permalink( $post ), [ 'aria-current' => 'page' ] );
$items = $breadcrumb_instance->get_items();
}
return $items;
}, 10, 2);
I’ve not had time to test the above code, but that’s the idea to solve it.
There is no functionality for sorting categories on this block, but there will be a functionality for you to choose a category/taxonomy as the primary category/taxonomy to show on the breadcrumb in the future version
Thanks, Phi.
-
This reply was modified 1 year, 9 months ago by Phi Phan.