From 54bdf05af132b21ac5c68d984762269da264e8c5 Mon Sep 17 00:00:00 2001 From: StevenDufresne Date: Tue, 23 Jan 2024 15:43:24 +0900 Subject: [PATCH] Update site title. --- .../themes/wporg-main-2022/functions.php | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/source/wp-content/themes/wporg-main-2022/functions.php b/source/wp-content/themes/wporg-main-2022/functions.php index 08693574..cf159651 100644 --- a/source/wp-content/themes/wporg-main-2022/functions.php +++ b/source/wp-content/themes/wporg-main-2022/functions.php @@ -19,6 +19,7 @@ /** * Actions and filters. */ +add_filter( 'document_title_parts', __NAMESPACE__ . '\document_title' ); 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 ); @@ -358,3 +359,26 @@ function update_header_template_part_class( $block ) { } return $block; } + +/** + * Append an optimized site name. + * + * @param array $parts { + * The document title parts. + * + * @type string $title Title of the viewed page. + * @type string $page Optional. Page number if paginated. + * @type string $tagline Optional. Site description when on home page. + * @type string $site Optional. Site title when not on home page. + * } + * @return array Filtered title parts. + */ +function document_title( $parts ) { + + if ( is_singular( 'and-handbook' ) ) { + // translators: %s: Name of the guide. + $parts['title'] = sprintf( __( '%s - Data Liberation', 'wporg' ), $parts['title'] ); + } + + return $parts; +}