After installing a SEO plugin, there are chances that your title attribute is displaying twice. You won’t recognize it until and unless you check it in the source or in the browser’s tab. For example, in the below screenshot you can see how bad the title looks in Google’s search result page.
This problem mostly appears after installing WordPress SEO by Yoast, All in One SEO Pack or any other SEO plugin. Fortunately, this problem is very easy to fix with the help of a simple tweak in your theme’s header.php file. Let’s take a closer look at this.
There are two ways to open your header.php file. Either use your WordPress admin to navigate to Themes > Editor and click on “header” from the right side or open your cPanel/FTP program and navigate to your theme’s directory and download this file.
Use your preferred code editor like Notepad++ or any other and search for “title” attribute and replace it with:
<title><?php wp_title(); ?></title>
For example, in my theme, I will replace the below code (but this code can be different in your theme):
<title><?php if (is_home() || is_front_page()) { echo bloginfo('name'); } else { echo wp_title(''); } ?></title>
With:
<title><?php wp_title(); ?></title>
Save changes, upload and replace your header.php file in your server.
That’s it. Now check out your front-end again and duplicate title problem should now be marked as solved.
Leave a Comment