• Resolved A.I. Sajib

    (@aisajib)


    I recently discovered a post and page title conflict with Twenty Twelve theme. My blog’s title “Around Android” was being displayed like this:

    A PostAround Android | Around Android

    While it was supposed to be like this:

    A Post | Around Android

    I’ve spent hours looking for the issue. And then suddenly I discovered the issue is happening to Twenty Twelve theme only. I rolled back to Twenty Ten or Twenty Eleven and the problem disappeared. Then I reactivated Twenty Twelve and deactivated All in one SEO pack plugin only to see that the problem was gone!

    That made me believe the plugin has some sort of conflict with Twenty Twelve theme. I’ve tried everything possible and the result was always same.

    Twenty Twelve + All in one SEO Pack = Duplicate Title
    Any other theme + All in one SEO Pack = OK
    Twenty Twelve + Deactivated All in one SEO Pack = OK

    Requesting plugin author’s attention.

    Example page: http://www.aroundandroid.com/2012/09/24/how-to-share-android-phones-internet-with-computer-via-usb-data-cable/

    http://wordpress.org/extend/plugins/all-in-one-seo-pack/

Viewing 15 replies - 1 through 15 (of 20 total)
  • aisajib,

    This is because Twenty Twelve is already adding the blog title into the page title in wp_title() on its own; you can correct this like so by running this code between when the wp_enqueue_scripts hook runs and when the wp_title hook runs:

    remove_filter( 'wp_title', 'twentytwelve_wp_title', 10, 2 );

    This is because Twenty Twelve is already adding the blog title into the page title in wp_title() on its own;

    Which is the current recommended best practice. See this Codex page.

    esmi,

    Using wp_title() is the current recommended best practice, yes; but having the theme append the blog title to the page title isn’t covered by that policy, which is the issue at hand presently.

    The wp_title() function should not be used by a theme in conjunction with other strings or functions (like concocting with bloginfo(‘name’) ) to set the title because it will render plugins unable to rewrite page titles correctly. The best practice is to use the wp_title filter with a callback function. This method is now a requirement for themes.

    http://codex.wordpress.org/Function_Reference/wp_title

    And there’s even an example in http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_title with uses get_bloginfo( 'name' ).

    esmi,

    Yes, we’re in agreement here, thanks.

    I don’t see how we can be. You seem to be implying that Twenty Twelve (the next WP default theme) is doing something wrong when, in fact, it is following all of the best practice recommendations.

    esmi,

    My issue is not that it can rewrite wp_title(), I agree that it can; however, it does rewrite wp_title(), in a way that the previous default themes did not. That’s not necessarily wrong, but it is a change in behavior, and therefore may be unexpected; what I provided was a way to make it function like the old behavior. The point to talk about would be, should a theme be doing this in the first place, or should it be left up to a plugin. So it’s not a question about theme guidelines; as far as I know, WPTRT doesn’t have guidelines relating to having SEO in themes.

    it does rewrite wp_title(), in a way that the previous default themes did not.

    The revisions have been made specifically so that plugins can hook into wp_title() far more easily as this was causing issues for other plugins – including, I think, SEO plugins.

    should a theme be doing this in the first place, or should it be left up to a plugin

    It’s gone well beyond that now. This IS the best practice recommendation for all WP themes and is mandated for all themes being submitted to the WPORG Repository.

    esmi,

    What is the best practice recommendation for having SEO embedded in a theme, then, or is there one?

    Rule of thumb: a theme shouldn’t be trying to do the job of a plugin (although, I agree that the line between the two can get a little fuzzy sometimes). Since the meta title tag is part of the HEAD section of any web page (WordPress generated or other), it’s seen as clearly part of a theme’s remit providing the theme ensures that some control remains in the hands of the site authors (via page titles etc).

    Not sure what the view would be regarding a submitted theme that auto-generated (for example) meta-descriptions. I’ve done that with custom themes myself – either by using the_excerpt_rss() or, even better, by adding it as a custom meta box to the Post/Pages Edit form. It might be acceptable if the theme also offered the option to turn this off (so as to avoid clashed with SEO plugins) but you’d need to check with the theme review team on that point.

    You also need to bear in mind that many site owners (myself included) don’t use SEO plugins at all but build SEO into the content of the site and perhaps use a Google XML sitemap plugin as well. Hand crafted, if you will. The Codex’s Search_Engine_Optimization_for_WordPress has the same initial approach & includes a lot of practical advise on the subject.

    Thanks for the advice and pointers, esmi!

    No problem. 🙂

    Peter, All,

    Same problem here, but I don’t understand the solution.

    running this code between when the wp_enqueue_scripts hook runs and when the wp_title hook runs:

    remove_filter( ‘wp_title’, ‘twentytwelve_wp_title’, 10, 2 );

    Where, exactly do i have to run this code: remove_filter( ‘wp_title’, ‘twentytwelve_wp_title’, 10, 2 );

    I mean, in which file do i have to insert the above line?

    update, i’ve added this:

    <?php remove_filter( ‘wp_title’, ‘twentytwelve_wp_title’, 10, 2 ); ?>

    to header.php above the title tag. Is that the right way to do it?

    margje,

    As long as it’s before when the title is getting output by wp_title(), then it should work. There will be a more comprehensive fix for this in the future, in the next major release, to allow better management of titles and title rewrites.

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘All in One SEO Pack Conflicts with Twenty Twelve’ is closed to new replies.