diff --git a/source/wp-content/themes/wporg-main-2022/functions.php b/source/wp-content/themes/wporg-main-2022/functions.php index ad36e283..3204c0f5 100644 --- a/source/wp-content/themes/wporg-main-2022/functions.php +++ b/source/wp-content/themes/wporg-main-2022/functions.php @@ -20,6 +20,7 @@ add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_assets' ); add_action( 'init', __NAMESPACE__ . '\register_shortcodes' ); add_filter( 'wp_img_tag_add_loading_attr', __NAMESPACE__ . '\override_lazy_loading', 10, 2 ); +add_filter( 'wporg_block_site_breadcrumbs', __NAMESPACE__ . '\update_site_breadcrumbs' ); // Enable embeds in patterns. // See https://github.com/WordPress/gutenberg/issues/46556. @@ -123,6 +124,32 @@ function override_lazy_loading( $value, $image ) { return $value; } +/** + * In the subpages, update first breadcrumb to be the parent page, rather than site home. + */ +function update_site_breadcrumbs( $breadcrumbs ) { + $parent = get_post_parent(); + if ( ! $parent ) { + return $breadcrumbs; + } + + if ( 'about' === $parent->post_name ) { + $top_level_page = array( + 'url' => home_url( '/about/' ), + 'title' => __( 'About', 'wporg' ), + ); + $breadcrumbs[0] = $top_level_page; + } else if ( 'download' === $parent->post_name ) { + $top_level_page = array( + 'url' => home_url( '/download/' ), + 'title' => __( 'Download', 'wporg' ), + ); + $breadcrumbs[0] = $top_level_page; + } + + return $breadcrumbs; +} + /** * Prevent Jetpack from looking for a non-existent featured image. */ diff --git a/source/wp-content/themes/wporg-main-2022/patterns/_nav-about-details.php b/source/wp-content/themes/wporg-main-2022/patterns/_nav-about-details.php index 364590d1..1fc28528 100644 --- a/source/wp-content/themes/wporg-main-2022/patterns/_nav-about-details.php +++ b/source/wp-content/themes/wporg-main-2022/patterns/_nav-about-details.php @@ -7,12 +7,12 @@ */ ?> - -