07-26-2023, 03:44 PM
I just added the following filter in my theme `functions.php` file:
function change_the_title() {
return 'My modified title';
}
add_filter('wp_title', 'change_the_title');
And in my `header.php`:
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta id="viewport" name="viewport" content="width=device-width">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
<?php wp_head(); ?>
</head>
<body <?php body_class();?>>
Then, I found the title of my page did **NOT** change! And the title tag was injected in the `wp_head` function.
More, if I call the function `wp_title` manually in the header, it does return the expected value.
What's the matter? How can I work around it?
---
Addition: My WordPress version is 4.4.
function change_the_title() {
return 'My modified title';
}
add_filter('wp_title', 'change_the_title');
And in my `header.php`:
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta id="viewport" name="viewport" content="width=device-width">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
<?php wp_head(); ?>
</head>
<body <?php body_class();?>>
Then, I found the title of my page did **NOT** change! And the title tag was injected in the `wp_head` function.
More, if I call the function `wp_title` manually in the header, it does return the expected value.
What's the matter? How can I work around it?
---
Addition: My WordPress version is 4.4.