WordPress wp_title blank on index page

nmford picture nmford · Jan 29, 2012 · Viewed 44.4k times · Source

I'm new to WordPress and just installed version 3.3.1.

I did some googling regarding this question and found some answers but they were relevant to version 2.7 and were 2-3 years old.

Basically, the wp_title function works fine on every page except my home page where it returns blank and I get no title whatsoever. I could just hard code the title in but I'd rather not do that.

Guilty line of code:

<title><?php wp_title ( '| So Fresh n\' So Clean', true,'right' ); ?></title>

I couldn't find anything regarding this problem happening in 3.3.1 so clearly I've done something wrong.

Answer

Amna Ahmed picture Amna Ahmed · Jan 29, 2012

Here's is what I read from Codex:

If you are using a custom homepage with custom loops and stuff, you will have an empty wp_title. Here goes a neat hack to add the description/tagline at the wp_title place on homepage:

<title><?php bloginfo('name'); ?> | <?php is_front_page() ? bloginfo('description') : wp_title(''); ?></title>

So use is_front_page() to get the title on homepage, the way it is suggested in above code.