[Plugin: WordPress SEO by Yoast] Title Rewrite Doesn't Work On Twenty Eleven Theme?
I’m using the Twenty Eleven theme for a very simple site, and Yoast SEO is having all kinds of issues with it. See here: http://moabmobile.com
The title’s like 500 characters long! Shouldn’t all plugins work with the default theme? Any ideas on how to fix this without modifying the theme? I don’t want the fix to get erased every time I update the plugin.
To preserve your theme changes, have a look here:
Yeah, I’m well aware of how to build child themes. It’s just a pain, and a lot of work for one little feature. Especially when the common thinking is that you’re supposed to be able to switch to the default theme to get baseline testing for any plugins, issues, etc. I’m just really surprised that Yoast SEO isn’t supporting proper rewrite of the title. I’d even be happy with an option that just let me turn off the title rules completely on some sites.
This really isn’t the fault of the plugin. It hooks into wp_title which is what it’s suppose to do. The theme builds the title by concatenating wp_title with other data. Any plugin that hooks into wp_title to set the title will have the same issue with the twentyeleven theme.
As already suggested you can create a child theme just for the header.php file. It’s probably less than 5 mins of work as you only need style.css and header.php in the child theme.
Alternatively, you can check the box for “Force rewrite titles” from the WordPress SEO Titles settings page. That feature actually does a replace on the entire html title tag so it should accomplish what you want without having to modify the theme code. You may experience a performance hit using this method as compared to the wp_title method.
BTW, this is outlined on the Titles settings page of the plugin.
Thank you. I tried turning on and off the “force rewrite titles” several times, it doesn’t seem to make a difference (or if it does, it’s not a very big one, and definitely doesn’t fix the problem).
I guess I’ll just have to settle for a child theme. The concern with child themes, is that once you create a new version of anything other than style.css and functions.php, they replace the parent theme files. So an update could still break the theme if there’s significant changes to the files (such as header.php in this case) in an update. Then you’re still forced to go through and either find what’s changed, or create a whole new file based on the new one, and go back and re-add your modifications. So it might save you time/hassle in minor updates, but could still result in just as much work in the long run. Sounds like I don’t have much choice though, and would see the same issue with the other major SEO plugins.
When you turn on “force rewrite titles” and set the title template to %%sitename%% does it still outputs more than sitename to the title tag? Are you using the latest version of the plugin? Any errors in the logs?
Do you have force rewrite on now?
Looking at the site it looks like you have it off and your Home page template settings is just the custom string and then the theme is appending sitename | tagline
I’ve tested force rewrite on WordPress SEO 1.1.5 and Twenty Eleven 1.3 and it works on my install.
Its turned on right now, and the page template is set as you suggest. It was already that way, except a custom title was added in the individual page title. I removed that, so it should be as you say, yet it’s still got MoabMobile twice with now space, right at the begging and the entire subtitle afterward.
Just to verify some settings
1) You have a Page created to be the home page?
2) Settings -> Reading -> Static Front page is set for the home page you created?
3) SEO -> Titles -> Force rewrite title = Checked?
4) SEO -> Titles -> Homepage & Front page = “You can determine the title and description for the front page by editing the front page itself “
5) SEO -> Titles -> Page -> Title Template = %%sitename%%% (for testing only)
6) Page -> Edit Page -> SEO Title = blank (of the page you are using as the static home page)
Go to home page, what is the page title?
SEO -> Titles -> Page -> Title Template = blank
Page -> Edit Page -> SEO Title = Home (of the page you are using as the static home page)
Go to home page, what is the page title?
The first 1-6 is how it’s currently set.
Removing the title template makes it “site name | subtitle”
Adding “Home” on the page SEO Title makes it “Homesite name | subtitle” without the proper space after home.
I really appreciate you working with me on this. I really didn’t understand why it didn’t work. Sorry it’s still not working.
It seems like you have all the right settings and the plugin is hooking into wp_title as expected. Even the output is expected and correct as you would concatenate wp_title and what is in the header.php code of the twentyeleven code.
The issue is that the “Force rewrite title” is not working for you. At this point, I think you need to look at server logs to see if there are errors. Or, start debugging the code to see if you can track down the issue.
Oh boy. I’m no coder, I wouldn’t know how to go through the logs or debug the code. Could this have something to do with Multisite?
No, it’s not a specific issue with Multisite. I run Multisite and have validated the settings on a Multisite install. That’s not to say that it couldn’t be something related to your specific configuration.
Hmmmmm… bummer, this is really frustrating. That makes sense that that’s the problem though. Are you associated with Yoast? Or just super helpful?
I may have to go with the WPMUDev SEO plugin then. I get support for it with my membership. I just don’t know how I’d do the debugging and such that you suggest.
No, I’m not affiliated with Yoast or this plugin.
Do you have other plugins installed? Have you tried disabling all other plugins to see if there’s a conflict?
I think I track down the problem as I happen to be working on another site. I wasn’t experiencing the issue you were having because I have other minification (stripping new lines among other things) plugins installed.
When using “force rewrite” the SEO plugin outputs to buffer then at the end extracts the buffer and does a preg_replace to substitute the entire html title tag. The regex pattern doesn’t handle new lines. So, if the theme is outputting the title across multiple lines, the regex won’t match and therefore it won’t rewrite the title.
I put in a minor patch that seems to be working on my sites and for my clients. I’ve also reached out to Yoast to submit the edit for review and inclusion in the next update.
Here’s the patch. Use at your own risk and no warranties are expressed or implied.
In plugins/wordpress-seo/frontend/class-frontend.php around line 830
$content = preg_replace('/<title>(.*)<\/title>/','<title>'.$title.'</title>', $content);
$content = preg_replace('/<title>(.*)<\/title>/sU','<title>'.$title.'</title>', $content);
The minor edit is the regex pattern modifiers that I added, sU.
s = treat string as single line
U = ungreedy
Great to find this threat and as a matter of fact I am experiencing similar problems where the sitename is showing double without a space.
I have started to experience this trouble on new sites only where I have installed the latest version of Yoast WordPress SEO, before I have never had any kind of problem with this and also on sites where I have the plugin already running for some time, everything still works fine.
@ming Sheu I have tried your patch, but that doesn’t seem to make any difference.
I am not using force rewrite as my header contains
I am using a twentyten child theme and this problem has just manifested itself as I just switched servers. On the old server I used headway, so I imported those settings and deleted headway.
- The topic ‘[Plugin: WordPress SEO by Yoast] Title Rewrite Doesn't Work On Twenty Eleven Theme?’ is closed to new replies.