Skip to content

Commit 1ce58f9

Browse files
authored
Merge pull request #14 from nikolailehbrink/main
Fix category breadcrumb display
2 parents 8058ccb + 2da2c13 commit 1ce58f9

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

WordPress-simple-URL-based-breadcrumb.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,24 @@ function get_the_crumbs() {
151151

152152
$slug = esc_html( urldecode( $crumb ) );
153153

154+
$taxonomies = get_taxonomies(
155+
array(
156+
'public' => true,
157+
),
158+
'objects'
159+
);
160+
161+
// Iterate through all the taxonomies.
162+
foreach ($taxonomies as $taxonomy) {
163+
// Check if there's a term with the given slug in the current taxonomy.
164+
if ($term = get_term_by('slug', $crumb, $taxonomy->name)) {
165+
// If a matching term is found, update the slug with the actual term name.
166+
$slug = $term->name;
167+
// Break the loop since a match has been found.
168+
break;
169+
}
170+
}
171+
154172
$url = esc_url( $server_scheme . '://' . $server_host . '/' . substr( implode( '/', $server_uri ), 0, strpos( implode( '/', $server_uri ), $crumb ) ) . $crumb. '/' );
155173

156174
array_push( $crumbs,
@@ -326,7 +344,7 @@ function the_bread( $ingredients = array() ) {
326344

327345
} else {
328346

329-
$title = ucfirst( str_replace( '-', ' ', $crumb['slug'] ) );
347+
$title = $crumb['slug'];
330348

331349
};
332350

0 commit comments

Comments
 (0)