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.
Here’s is what I read from Codex:
So use
is_front_page()
to get the title on homepage, the way it is suggested in above code.But if you use a static home page, this is the code:
Update
for WordPress versions (>= 4.4)
Try this
Do this in functions.php and remove ‘title’ tag from head…
Working off of Amna’s answer, I came up with the following code which should display the page title when there is one, followed by the site name.
Post/Page Outputs: “The Page Title – Site Name”
Home Page Outputs: “Site Name”
Obviously, this can also be swapped to display the site name first.
Post/Page Outputs: “Site Name – The Page Title”
Home Page Outputs: “Site Name”
This can also be combined with a conditional to display the site description when viewing the home page.
Post/Page Outputs: “Site Name – The Page Title”
Home Page Outputs: “Site Name – The Site Description”
For google search on wordpress wp_title empty this is the first result. So I thought that I might share the most elegant solution for this.
In functions.php add a filter for wp_title.
The new hack from Codex is as follows:
Then in your “functions.php” from theme file :
I use this one and it never failed:
Note that there are translation domains in it that you might want to change.
no need. Just add the
<? Php wp_head ();?>
Code at the end of the header.phpgood luck.
I use this method in my WordPress site
Late to the conversation…
But if you want to use the actual title of the page that you are using for the static front page, you can use the following:
Although, in the actual source for wp_title(), there is the following, specificaly disabling this for the static front page:
I suspect there is good reason for this. So, proceed with caution.
My 2 cents for “misty lake” theme which had no title on home page and added incorrect title on all other pages.
Just removing the following line from header.php solves the issue, since WordPress now injects the tag by itself:
I consulted the following page â https://make.wordpress.org/themes/2015/08/25/title-tag-support-now-required/
You could also put something like this inside your title tag: