WordPress 3.0 twentyten_filter_wp_title conflict with All in One SEO
Just upgraded to WordPress 3.0? Are you using the TwentyTen theme? Do you have All in One SEO installed? Are your page titles now screwed up?
TwentyTen is a very clean and practical theme and, unlike the previous default, is perfectly acceptable as a production theme. I’ve created a child theme 95% based on TwentyTen as a rapid deployment template and it works really well apart from one niggle with the page titles.
TwentyTen tries to pick up some of the title rewriting capability found in plugins like All in One SEO pack but I prefer the latter and would rather WordPress leave my titles alone. There’s also an error whereby the site name is jammed up against the page name without any spacing and this looks ugly and could have implications for SEO.
WordPress does the rewriting using the function twentyten_filter_wp_title() found in the theme’s functions.php file. It hooks wp_title to achieve the end result. An easy way to undo the rewrite would be to disable the filter in the parent theme but on the next upgrade the filter would be restored.
So I’ve applied remove_filter in my child theme’s header.php file and that should do the trick no matter how many times TwentyTen is upgraded.
Getting to the point, here’s the relevant section in my child header.php, the code you need to add is in red:
<title><?php
/**
* Stop TwentyTen parent theme rewriting the page titles
* Leave this job to All in One SEO
*/
remove_filter( 'wp_title', 'twentyten_filter_wp_title', 10 );
/*
* Print the <title> tag based on what is being viewed.
* We filter the output of wp_title() a bit -- see
* twentyten_filter_wp_title() in functions.php.
*/
wp_title( '|', true, 'right' );
?></title>
Obviously this only applies if you are using a child theme based on TwentyTen. If you are hacking the parent directly then comment out the following in the main theme functions.php file to achieve the same result:
// add_filter( 'wp_title', 'twentyten_filter_wp_title', 10, 2 );

Yes, that did the trick! I was expecting quite a trawl to find a solution to this problem.
Many thanks.
Stephen TBA´s last blog ..Twitter Karma – easily find out who doesn’t follow you back on Twitter