• Resolved Anonymous User 13812167

    (@anonymized-13812167)


    Good day,

    I have recently introduced add_theme_support( 'title-tag' ); into my theme and adjusted it accordingly (i.e. removed <title> tags and all other code telling how and where to render title). This broke title rewriting functionality of the plugin.

    Namely, all titles started to appear as %page_title%%blog_title% | %blog_title%, though in the plugin settings it was set to simply %page_title% | %blog_title%. I guess that wordpress does some additional pre- or post- filtering of the title.

    Disabling title rewriting solved the problem only partially – ordinary titles now appear as they should, while og:title meta tags still contain titles rendered as %page_title%%blog_title% | %blog_title%.

    Any suggestions how to solve this problem?

    https://www.ads-software.com/plugins/all-in-one-seo-pack/

Viewing 13 replies - 1 through 13 (of 13 total)
  • Hi aliuskon,

    This should be supported in All in One SEO Pack; to verify, try testing against Twenty Fifteen, which also uses the title-tag theme support. Do you know if wp_title is getting filtered elsewhere in your theme, or could this be due to a plugin conflict as well? Also, are you seeing actual percent signs in the markup etc.

    Thread Starter Anonymous User 13812167

    (@anonymized-13812167)

    I have used percent signs just to clearly state the problem. No percent signs appear in the actual output – only the correct respective values. Lets say, if page title is “abc” and blog title is “DEF”, I observe og:title output value being abcDEF | DEF, though normal title (inside <title> tags) value is abc | DEF.

    I have looked into how the post title changes while being processed by All in One SEO Pack plugin. I have arrived at get_original_title function, which calls
    $title = wp_title( $sep, $echo, $seplocation );
    where $sep='', $echo=false, $seplocation=''. This line of code seems to return the post title as abcDEF. So there is no error in actual processing by All in One SEO Pack. It appears to be incorrect call to wp_title function or incorrect response by it.

    As far as I can tell only the default functions are associated with wp_title filter.

    Test with Twenty Fifteen produced the same og:title. I have done the test on a local computer with only Twenty Fifteen and All in One SEO Pack enabled. No other plugins were present.

    Disabling “Use original title” helped (on both test website and my true website). But it is simple bypass for the actual problem. Isn’t it?

    Hi aliuskon,

    Thanks for clarifying this. Usually when something like this happens, it means that something else (another plugin or the theme) is filtering wp_title() or sometimes echoing other information in the header that isn’t being rewritten. I’m not sure why you’re seeing different results in your test environment, as it should be similar to mine. This is still with vanilla WordPress 4.1? You’re correct that that option is a simple bypass for the actual problem, but that’s why it exists – as a workaround for bad behavior by other themes and plugins.

    Thread Starter Anonymous User 13812167

    (@anonymized-13812167)

    Yes. I run vanilla WordPress 4.1, no other plugins except All in One SEO Pack, no other themes except Twenty fifteen. Just to confirm I have fully “reinstalled” from scratch.

    I would like to observe that in my test environment All in One SEO Pack “disabled” option (on “Use original title”) was active out of the box. So initially, before checking the plugin settings, I had the impression that everything works, but after choosing to “enable” everything broke.

    I have also tried to run only the following line (without All in One SEO Pack)
    echo wp_title('',false,'');
    The output is the same – “Post TitleMy Website”.

    aliuskon,

    Out of the box, that setting should be disabled; the only real reason to use it is if you run into a conflict with a theme or plugin and how it outputs its titles. Does it work properly with that option enabled?

    Thread Starter Anonymous User 13812167

    (@anonymized-13812167)

    Everything works well if “Use Original Title” is set to “Disabled”. If this option is “Enabled”, then the contents of og:title and <title> (last one only if title rewriting is enabled) are badly formatted (“Post titleMy Website | My Website”).

    Explanation bellow “Use Original Title” states “Use wp_title to set the title; disable this option if you run into conflicts with the title being set by your theme or another plugin.” So I understand that this option should be disabled only if there are problems, not out of the box.

    As far as I can see the problem is on the line 2462 of aioseop_class.php:
    $title = wp_title( $sep, $echo, $seplocation );
    wp_title does not return post title only, it returns string which is to be written into <title> tags.

    aliuskon,

    It seems to me that you are running into problems with it, and therefore should keep it Disabled, as the help text, which I wrote, clearly states. wp_title() should return the page title; some themes add other things into the title tag outside of wp_title(), which they are not supposed to do, as per the Codex. And that is why this option is disabled out of the box. However, all that still doesn’t explain why you’re seeing this behavior on a vanilla WordPress install with Twenty Fifteen, and I’m not. I’m somewhat at a loss there to explain that. What platform are you running your site on, and which version of PHP are you using? Try resetting All in One SEO Pack to default settings, and see what the title tag is; the other options to look at there are Force Rewrites under Performance, and Use Original Title of course.

    Thread Starter Anonymous User 13812167

    (@anonymized-13812167)

    I have tested and obtained the same results in two different environments – Windows computer with PHP 5.3.6, Linux (OpenSuse) server with PHP 5.2.6.

    I have also looked into wp_title page on Codex and also into its code on wp-includes/general-template.php. I believe that Codex page was not updated to reflect changes done in WP 4.0 (from line 844 to 872). As far as I can understand the site title is appended to the return title if theme supports title-tag and other page than feed is viewed (see from line 861):

    if ( current_theme_supports( 'title-tag' ) && ! is_feed() ) {
    	$title .= get_bloginfo( 'name', 'display' );
    	$site_description = get_bloginfo( 'description', 'display' );
    	if ( $site_description && ( is_home() || is_front_page() ) ) {
    		$title .= " $sep $site_description";
    	}
    	if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
    		$title .= " $sep " . sprintf( __( 'Page %s' ), max( $paged, $page ) );
    	}
    }

    To test this I have simply run the following code put into a new randomly named file (tst.php) in WordPress root directory:

    include('wp-load.php');
    query_posts("p=1");
    echo wp_title();

    The output was “? Hello world!Site Title”.

    Hi aliuskon,

    I did some more testing and I finally was able to reproduce this; I didn’t find any problems on the front page, but I do see the issue on the posts page with Use Original Title enabled. Thanks for helping troubleshoot this, I’ll see about fixing this issue for the next release.

    Thread Starter Anonymous User 13812167

    (@anonymized-13812167)

    Thank you for providing support for useful and increasingly complex plugin! ??

    Hi aliuskon,

    The update is now live and ready for you to test; let me know if it fixes your issue!

    Thread Starter Anonymous User 13812167

    (@anonymized-13812167)

    Hello,
    I am currently on a very busy schedule so I am replying with large delay and also I can’t make detailed tests. As far as I can see everything works if “Use Original Title” is disabled. The same problem og:title being “Post TitleWebpage | Webpage” format is still present if the option is enabled.

    Hi aliuskon,

    Thanks for testing this! I’ll see about syncing the two for the cases when the og:title uses the same title, for the next release.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘title-tag support and badly formated titles’ is closed to new replies.