WordPress.org

Ready to get started?Download WordPress

Forums

WordPress SEO by Yoast
Title Rewrite Doesn't Work On Twenty Eleven Theme? (27 posts)

  1. Tevya
    Member
    Posted 2 years ago #

    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.

    http://wordpress.org/extend/plugins/wordpress-seo/

  2. Jerome
    Member
    Posted 2 years ago #

    To preserve your theme changes, have a look here:

    http://codex.wordpress.org/Child_Themes

  3. Tevya
    Member
    Posted 2 years ago #

    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.

  4. Ming Sheu
    Member
    Posted 2 years ago #

    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.

  5. Tevya
    Member
    Posted 2 years ago #

    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.

  6. Ming Sheu
    Member
    Posted 2 years ago #

    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.

  7. Tevya
    Member
    Posted 2 years ago #

    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.

  8. Ming Sheu
    Member
    Posted 2 years ago #

    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?

    For testing

    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?

  9. Tevya
    Member
    Posted 2 years ago #

    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.

  10. Ming Sheu
    Member
    Posted 2 years ago #

    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.

  11. Tevya
    Member
    Posted 2 years ago #

    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?

  12. Ming Sheu
    Member
    Posted 2 years ago #

    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.

  13. Tevya
    Member
    Posted 2 years ago #

    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.

  14. Ming Sheu
    Member
    Posted 2 years ago #

    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?

  15. Ming Sheu
    Member
    Posted 2 years ago #

    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

    Replace

    $content = preg_replace('/<title>(.*)<\/title>/','<title>'.$title.'</title>', $content);

    With

    $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

  16. Piet
    Member
    Posted 2 years ago #

    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
    <title><?php wp_title('');?></title>
    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.

  17. Ming Sheu
    Member
    Posted 2 years ago #

    Hi Piet,

    If you are not using force rewrite and your header file is coded as suggested then you have a completely different problem than the original poster.

    Please start a new thread with as much details as you can and we'll go from there.

  18. Piet
    Member
    Posted 2 years ago #

    Hi Ming Sheu, ok. Actually - as this problem is manifesting itself on quite a few of my sites - what I am going to do is to replace <title><?php wp_title('');?></title> in my header.php file with something that outputs the value of the metabox yoast_wpseo_title directly. That way I no longer have to waste any of my time nor that of others and it will work as I want it to :)

  19. Tevya
    Member
    Posted 2 years ago #

    I made that change as you suggested Ming, but it still doesn't work. I've played around with it quite a bit now and "force rewrote titles" doesn't seem to have any effect. Any other ideas?

  20. Ming Sheu
    Member
    Posted 2 years ago #

    Just checked your site and the title tags look clean. Did you get it working or moved to another plugin?

    Home page is custom string and the other pages are title | sitename

  21. OC2PS
    Member
    Posted 2 years ago #

    Tevya? What Ming asked.

  22. Ross100
    Member
    Posted 2 years ago #

    I am also using Twenty Eleven 1.3 and therefore have the same issue. It is a great plugin but....I have copied the header.php to my child theme and removed the existing <title>.......</title> and replaced with <title><?php wp_title('');?></title> but the Home page, for instance, just lists the browser name in the title. All is cured by disabling the plugin. So I will enable it to create posts and disable it afterwards until there is a fix. It would be good to know when a fix is available.

  23. mbrinson
    Member
    Posted 2 years ago #

    I'm having the same issue. I've been able get this working with other themes by following this post -> http://www.brintech.net%2Fwordpress-title-problems-yoast-seo-title-broken-or-not-working-but-actually-its-your-theme%2F
    but I can't get it working for twentyeleven.

  24. mbrinson
    Member
    Posted 2 years ago #

    Update:
    It looks like Yoast wrote about this, it just wasn't easy for me to find for some reason.

    http://yoast.com/wordpress-themes-page-title/

    The problem is explained very well in the post and some extra insights are gained by reading the comments at the bottom.

  25. Ross100
    Member
    Posted 2 years ago #

    Interesting, so does it mean that the core will or will not be changed?

  26. ameade19
    Member
    Posted 2 years ago #

    Hi, I am also using SEO by yoast. I have been changing the SEO title and Meta Description for my front page (beaconspoint.com) and it has not changed in the search results. I changed over a week and, and it has not updated. Any advice? does it take time to change? the page titles have changed though. Not sure.

    thanks

  27. dariuF
    Member
    Posted 2 years ago #

    Does anyone figure out how to rewrtie titles? I have the same problem on http://www.pipinga.com

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic