If WordPress title appears twice or is blank


Strange things can happen with the WordPress title in a Home / Front page, according to the particular theme one uses or specialized configurations, when a blog belongs to a multi-site environment or is a single installation. Sometimes in a blog’s Home page you may see that its title is repeated. A solution to this problem would be to replace the current code in the <title> tags of your theme’s header page with

<?php wp_title(" - ",TRUE,"right"); ?>

This is precisely the code that other times leads to a blank title! Adding bloginfo(‘name’) solves this only to create the problem of a possible double title!

Here is a way to end the vicious circle:

<?php if (is_home() || is_front_page()) { bloginfo("name"); echo " - "; bloginfo("description"); } else { wp_title(" - ",TRUE,"right"); } ?>

In this example, with a simple code, without using a plugin and without taking into account all possible conditions (if it is a 404 page, or if it is tag archives, etc), we give always in Home / Front page the general title and description of the blog, in other sections letting WordPress decide following the default wp_title code, only placing the separator at the right — which may lead to a needless (orphan) hyphen at the end of the title in many cases, not a serious problem in my opinion, at least compared with double or blank titles.

According to the specific theme that is used each time, especially in configurations that feature some category in the front page, even this code won’t give the desired results, saving from a double or empty title, but getting the title of the featured category instead of the general title of the blog along with the description of it. However, it is a working and simple solution to the main problem. If you know of a better one, just drop a note and let me add it on this page. Enjoy!