If you want to change your page title dynamically which change the title tag <title>, check whether your theme has this code under functions.php
|
1 2 3 4 5 6 7 |
/* * Let WordPress manage the document title. * By adding theme support, we declare that this theme does not use a * hard-coded <title> tag in the document head, and expect WordPress to * provide it for us. */ add_theme_support( 'title-tag' ); |
If yes, if you want to change the page title dynamically, you must call below filter.
|
1 2 3 4 5 6 |
add_filter( 'pre_get_document_title', 'change_browser_page_title'); function change_browser_page_title () { return "Custom title"; } |
Check that your theme header.php doesn’t contain any title tag. It only contains wp_head()
|
1 2 3 4 5 |
<head> <meta charset="<?php bloginfo( 'charset' ); ?>"> <meta name="viewport" content="width=device-width"> <?php wp_head(); ?> </head> |
I spent so much time finding this solution, maybe I didn’t typed the right keywords in search engine.