Skip to content

Commit 63e1bb3

Browse files
authored
Merge pull request #16 from nikolailehbrink/main
Enhance breadcrumb accessibility and structure
2 parents 3b4a4d2 + c36c635 commit 63e1bb3

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

WordPress-simple-URL-based-breadcrumb.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ function the_bread( $ingredients = array() ) {
323323

324324
if ( ! empty( $crumbs ) ) {
325325

326+
echo '<nav aria-label="Breadcrumb">';
327+
326328
echo '<ol class="🍞 bread" itemscope itemtype="https://schema.org/BreadcrumbList">';
327329

328330
$i = 0;
@@ -349,21 +351,31 @@ function the_bread( $ingredients = array() ) {
349351
};
350352

351353
echo '<li class="crumb" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
352-
<a itemprop="item" href="' . $crumb['url'] . '">
354+
<a itemprop="item" href="' . $crumb['url'] . '"';
355+
356+
if ( $i === sizeof( $crumbs ) ) {
357+
echo ' aria-current="page"';
358+
}
359+
360+
echo '>
353361
<span itemprop="name">' . $title . '</span>
354362
</a>
355-
<meta itemprop="position" content="' . $i . '">
356-
</li>';
363+
<meta itemprop="position" content="' . $i . '">';
357364

358365
if ( $i !== sizeof( $crumbs ) && ! empty( $ingredients['separator'] ) ) {
359366

360367
echo $ingredients['separator'];
361368

362369
};
363-
370+
371+
echo '</li>';
372+
373+
364374
};
365-
375+
366376
echo '</ol>';
377+
378+
echo '</nav>';
367379

368380
};
369381

0 commit comments

Comments
 (0)