breadcrumb first crumb is always “home”
-
The first crumb of the breadcrumb path is always hardcoded as “Home”.
Especially for multi language sites this is not optimal.Also the active crumb element is missing
aria-current="page"
(see https://getbootstrap.com/docs/5.2/components/breadcrumb/)
How I fixed the issues atm:
Modify helpers.php@127 (function areoi_generate_breadcrumbs)
if ( $post->post_parent ) { $breadcrumbs = areoi_generate_breadcrumbs_parent( $breadcrumbs, $post->post_parent ); $title = __('Home'); $front_page_id = (int)get_option('page_on_front'); if ($front_page_id > 0) { $title = get_the_title( $front_page_id ); } $breadcrumbs[] = array( 'permalink' => home_url(), 'label' => $title, 'active' => false ); }
(If you only want to have Home translated, then remove the whole “$front_page_id” logic.)
To fix the missing aria-current attribute, modify blocks/breadcrumb.php@21
$list .= '<li class="breadcrumb-item active" aria-current="page">' . $breadcrumb['label'] . '</li>';
@devs would be great to have this fixed / improved in the next version.
Maybe add an option to the breadcrumb block (or global) to decide if the front_page title or the translated “Home” label should be used.
- The topic ‘breadcrumb first crumb is always “home”’ is closed to new replies.