Skip to content

Commit

Permalink
Block theme: Add the category name to filtered search results breadcr…
Browse files Browse the repository at this point in the history
…umbs

See #674 (comment)
  • Loading branch information
ryelle committed Apr 18, 2024
1 parent 88a0b8f commit 369e7c7
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ function update_site_breadcrumbs( $breadcrumbs ) {
$term_names = wp_list_pluck( $term_names, 'name' );
$breadcrumbs[] = array(
'url' => false,
// translators: %s list of terms used for filtering.
'title' => implode( ', ', $term_names ),
);
}
Expand All @@ -485,6 +484,17 @@ function update_site_breadcrumbs( $breadcrumbs ) {
'url' => home_url( '/' ),
'title' => __( 'All patterns', 'wporg-patterns' ),
);

// If there is a cateogry, show it.
if ( $term_names ) {
$url = get_term_link( $term_names[0] );
$term_names = wp_list_pluck( $term_names, 'name' );
$breadcrumbs[] = array(
'url' => $url,
'title' => implode( ', ', $term_names ),
);
}

$breadcrumbs[] = array(
'url' => false,
'title' => __( 'Search results', 'wporg-patterns' ),
Expand Down Expand Up @@ -513,7 +523,6 @@ function update_site_breadcrumbs( $breadcrumbs ) {
$term_names = wp_list_pluck( $term_names, 'name' );
$breadcrumbs[] = array(
'url' => false,
// translators: %s list of terms used for filtering.
'title' => implode( ', ', $term_names ),
);
}
Expand Down

0 comments on commit 369e7c7

Please sign in to comment.