Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

hdetail
17,750 PointsWordpress Title Tag
I'm using a static front-page for my wordpress site and the site title keeps displaying a "-" before my site name.
Any idea what's wrong?
<?php
if (function_exists('is_tag') && is_tag()) {
single_tag_title("Tag Archive for ""); echo '" - '; }
elseif (is_archive()) {
wp_title(''); echo ' Archive - '; }
elseif (is_search()) {
echo 'Search for "'.wp_specialchars($s).'" - '; }
elseif (!(is_404()) && (is_single()) || (is_page())) {
wp_title(''); echo ' - '; }
elseif (is_404()) {
echo 'Not Found - '; }
if (is_front_page()) {
bloginfo('name'); echo ' - '; bloginfo('description'); }
else {
bloginfo('name'); }
if ($paged>1) {
echo ' - page '. $paged; }
?>
6 Answers

hdetail
17,750 PointsSorry about the formatting...

Zac Gordon
Treehouse Guest TeacherHi Spyros,
One thing I noticed is that it looks like there is an extra parenthesis here in your first if statement
single_tag_title("Tag Archive for ""); echo '" - ';
Should be
single_tag_title("Tag Archive for "); echo '" - ';
Try fixing that and see if it changes anything, if not, I'll take another look :)

hdetail
17,750 PointsNah no difference :/

hdetail
17,750 PointsI just went back to using the default Twenty Eleven title. Chickened my way out of it :(

chrisfeld
3,332 PointsYou can modify title tags for your blog from wordpress admin area - settings -> general I always use an SEO plugin (Yoast WordPress SEO is great and free) to generate an SEO title tag.

Zac Gordon
Treehouse Guest TeacherI would definitely recommend an SEO plugin for this as well. It will take some of the complexity out of your template code and allow for more flexibility and customization of the title tags.