Support » Plugin: Yoast SEO » Wrong meta title name on author pages

  • Resolved YuriV

    (@yuriv)


    Hi,

    Since Yoast 12.4 the meta title on the archive page of our guest authors isn’t displaying the right author anymore.

    Instead of the name of the Guest Author (from Co Author Plus), it’s displaying the name of the administrator who created the Guest Author. Before 12.4 the right meta titles were shown.

    Something must have been changed. Any idea what’s the problem here?

    Regards, Yuri

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • I think that’s most likely an issue in Co-Authors Plus plugin. I just found an issue on their Github – https://github.com/Automattic/Co-Authors-Plus/issues/643

    Are you sure that’s changed between versions 12.3 and 12.4?

    Thread Starter YuriV

    (@yuriv)

    Hi Saša,

    Thanks. I’ll try the possible fix.

    I’m not 100% sure it changed between versions 12.3 and 12.4. But it worked for a long time and I found out the wrong meta title was shown shortly after I updated Yoast. In the meantime Co Author Plus didn’t have any updates.

    Regards, Yuri

    Thread Starter YuriV

    (@yuriv)

    Unfortunately the snippet you provided in your answer didn’t solve the issue.

    I then deactivated Yoast => Meta title of the Author page of Co Authur Plus showed the right name
    Re-activated Yoast => Wrong co-author shown in page meta title (name of site administrator is shown instead)

    I then tried to change some code in Yoast > Search Appearance > Archives:

    Removed the snippet codes on the line SEO Title => Opened author archive: only displaying name of site administrator as meta title

    Tested a bit: any info we write in the field SEO-title isn’t displayed when we open a author archive. It’s totally ignored.

    ==================================================

    This snippet solves the issue:

    /*Filter to modify the author display name on author page title for co-authors plus guest authors.*/
    /*Solution for issue with yoast seo and co-authors plus guest author name reading for title of author page.*/
    
    add_filter( 'wpseo_title', 'filterAuthorTitle' );
    function filterAuthorTitle( $title ) {
    //check if author page, if it's not return as it is
    if ( ! is_author() ) {
    return $title;
    }
    //its author page, so let's pull current author name
    $current_display_name = get_the_author_meta( 'display_name', get_query_var( 'author' ) );
    $authorobj = get_queried_object();
    $new_display_name = $authorobj->display_name ;
    return str_replace( $current_display_name, $new_display_name, $title );
    }

    Found here: http://www.prowebguru.com/2017/06/wrong-author-page-title-co-authors-plus/#.Xcl0te1Ar-c

    Implemented this code and now the right Author Meta Title is shown. It’s a fix but it would be better of course if Yoast fixed it in the plugin itself.

    • This reply was modified 1 year, 11 months ago by YuriV. Reason: extra info

    It seems that query variable author and queried_object point to different authors. I don’t remember all details, but it’s possible that the root of cause is other plugin or theme. Do you remember which plugins were updated before you noticed changed title?

    I’ve compared class WPSEO_Frontend between last few versions of Yoast SEO (12.x) and I don’t see big differences.

    Thread Starter YuriV

    (@yuriv)

    We updated Mailpoet and AMP (Official plugin) around this time.

    I’ve tried to reproduce it with very old versions (probably it never worked). Yoast shows wrong title when guest author isn’t “real user” (not mapped to real user). Co-Authors plus doesn’t populate query variable author (which is user ID).

    I’ve created simple workaround using filter wpseo_replacements:

    add_filter( 'wpseo_replacements', function( $replacements ) {
    
    	if ( ! is_author() || get_query_var( 'author' ) ) {
    		return $replacements;
    	}
    
    	$author = get_queried_object();
    	if ( is_object( $author ) && property_exists( $author, 'display_name' ) ) {
    		$replacements['%%name%%'] = $author->display_name;
    	}
    
    	return $replacements;
    } );
    

    I think Yoast can’t easy fix it in their code. Please try to create new issue (or comment existing issues) on Co-Authors Plus forum or github.

    Thread Starter YuriV

    (@yuriv)

    Thanks for your work. Test the snippet but it didn’t solve the issue on our end. The snippet I posted earlier does work:

    /*Filter to modify the author display name on author page title for co-authors plus guest authors.*/
    /*Solution for issue with yoast seo and co-authors plus guest author name reading for title of author page.*/
    
    add_filter( 'wpseo_title', 'filterAuthorTitle' );
    function filterAuthorTitle( $title ) {
    //check if author page, if it's not return as it is
    if ( ! is_author() ) {
    return $title;
    }
    //its author page, so let's pull current author name
    $current_display_name = get_the_author_meta( 'display_name', get_query_var( 'author' ) );
    $authorobj = get_queried_object();
    $new_display_name = $authorobj->display_name ;
    return str_replace( $current_display_name, $new_display_name, $title );
    }
    Plugin Support Pcosta88

    (@pcosta88)

    @yuriv

    Hi, we are glad the issue has been resolved and we will close this issue in order to keep the overview.

    Please know that Yoast overwrites titles so depending on how the Co Author plugin has been designed it may result in unexpected behavior. We had an issue report related to this issue reported here https://github.com/Yoast/wordpress-seo/issues/13156 and the solution provided is to disable the ability of Yoast to overwrite titles using the filter here https://github.com/Yoast/wordpress-seo/issues/13156.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Wrong meta title name on author pages’ is closed to new replies.