Skip to content

Commit 369e7c7

Browse files
committed
Block theme: Add the category name to filtered search results breadcrumbs
See #674 (comment)
1 parent 88a0b8f commit 369e7c7

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

public_html/wp-content/themes/wporg-pattern-directory-2024/inc/block-config.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,6 @@ function update_site_breadcrumbs( $breadcrumbs ) {
466466
$term_names = wp_list_pluck( $term_names, 'name' );
467467
$breadcrumbs[] = array(
468468
'url' => false,
469-
// translators: %s list of terms used for filtering.
470469
'title' => implode( ', ', $term_names ),
471470
);
472471
}
@@ -485,6 +484,17 @@ function update_site_breadcrumbs( $breadcrumbs ) {
485484
'url' => home_url( '/' ),
486485
'title' => __( 'All patterns', 'wporg-patterns' ),
487486
);
487+
488+
// If there is a cateogry, show it.
489+
if ( $term_names ) {
490+
$url = get_term_link( $term_names[0] );
491+
$term_names = wp_list_pluck( $term_names, 'name' );
492+
$breadcrumbs[] = array(
493+
'url' => $url,
494+
'title' => implode( ', ', $term_names ),
495+
);
496+
}
497+
488498
$breadcrumbs[] = array(
489499
'url' => false,
490500
'title' => __( 'Search results', 'wporg-patterns' ),
@@ -513,7 +523,6 @@ function update_site_breadcrumbs( $breadcrumbs ) {
513523
$term_names = wp_list_pluck( $term_names, 'name' );
514524
$breadcrumbs[] = array(
515525
'url' => false,
516-
// translators: %s list of terms used for filtering.
517526
'title' => implode( ', ', $term_names ),
518527
);
519528
}

0 commit comments

Comments
 (0)