• Resolved davereed

    (@davereed)


    I’m finding that the SEO Framework is not outputting the correct author information when using the Co-Authors Plus plugin.

    It’s generating the correct author archive link, but it’s not using the name of the Co-Author for the <title> attribute. Instead it’s outputting the name of the user that created the Guest Author record in the Co-Authors Plus plugin system.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hello!

    I remember I dug into the aforementioned plugin a few years ago. Here are my comments: https://www.ads-software.com/support/topic/author-archives-title-changes-with-recent-updates/#post-9045406

    In that, we found that the plugin only addresses corrections for HTML templates and not the acquirer of the archive title: get_the_author().

    This workaround snippet should fix that, however–regardless if you’re using The SEO Framework or not:

    add_filter( 'the_author', function( $author ) {
    
    	if ( isset( $GLOBALS['coauthors_plus'] ) && method_exists( $GLOBALS['coauthors_plus'], 'get_coauthor_by' ) ) {
    		$author_slug = sanitize_user( get_query_var( 'author_name' ) );
    		$author_obj  = $GLOBALS['coauthors_plus']->get_coauthor_by( 'user_nicename', $author_slug );
    
    		$author = isset( $author_obj->display_name ) ? $author_obj->display_name : $author;
    	}
    
    	return $author;
    } );

    @batmoo Could you look into this? Thank you!

    Thread Starter davereed

    (@davereed)

    Thanks Sybre, this is helping.

    It works correctly for the title tag. However, when you’re on the author archive page, it’s replacing the names of other authors on the posts with the guest author name. The links to the other authors are correct, but their name is displaying incorrectly.

    Example: It should be outputting this where Author 3 is the guest author registered through the Co-Author’s Plus plugin:

    By Author 1, Author 2 and Author 3

    Instead it’s outputting this:

    By Author 3, Author 3 and Author 3

    The links to the different authors are correct, but their name is displayed incorrectly.

    Plugin Author Sybre Waaijer

    (@cybr)

    Hi @davereed

    I apologize for my absence.

    This updated snippet will only target the title, without affecting the Author query elsewhere, mitigating the issue you experienced.

    add_filter( 'the_seo_framework_the_archive_title', function( $title, $term ) {
    
    	if ( isset( $term->display_name, $term->type ) && 'guest-author' === $term->type ) {
    		$use_prefix = the_seo_framework()->use_generated_archive_prefix();
    
    		$title = $use_prefix ? sprintf( \__( 'Author: %s', 'default' ), $term->display_name ) : $term->display_name;
    	}
    
    	return $title;
    }, 10, 2 );

    I hope this one does the trick well for you ?? Have a great day!

    Thread Starter davereed

    (@davereed)

    Hey @cybr, No problem and I appreciate the help.

    I’m working with your new snippet. Here’s what SEO Framework is outputting i nthe meta data:

    <meta name="robots" content="max-snippet:-1,max-image-preview:standard,max-video-preview:-1" />
    <meta name="description" content="DESCRIPTION OF NORMAL USER" />
    <meta property="og:locale" content="en_US" />
    <meta property="og:type" content="profile" />
    <meta property="og:title" content="Guest Author | SITENAME" />
    <meta property="og:description" content="DESCRIPTION OF NORMAL USER" />
    <meta property="og:url" content="https://dev.local/author/guest-author/" />
    <meta property="og:site_name" content="SITENAME" />
    <meta name="twitter:card" content="summary_large_image" />
    <meta name="twitter:title" content="Guest Author | SITENAME" />
    <meta name="twitter:description" content="DESCRIPTION OF NORMAL USER" />
    <link rel="canonical" href="https://dev.local/author/guest-author/" />

    The “Normal User” it’s pulling data from is the admin user who created the Guest Author via the Co-Authors Plus plugin. It’s outputting the correct name for the Guest Author in the meta data, but missing these other fields.

    In addition, I’m back now to the problem of not having the Guest Author’s name appear on the author archive. It should be appearing in the header inside an H2 tag, but it’s just blank again.

    I really appreciate your time looking into this.

    Plugin Author Sybre Waaijer

    (@cybr)

    Hi again!

    I almost never do this, but I’m afraid I must pull the “out of scope” card. The issues you’re experiencing are a mixture of templating and low-level query assertions. To address these issues, you’ll need to filter every single generator in The SEO Framework and address your theme’s templates. This is tedious and requires a lot of time and guidance maintaining. Unfortunately, this is something I can’t afford to spend time on.

    The Co-Authors Plus plugin is in need of refactorization. The first code-snippet I provided here is the first step to this, where AFAIK only the By Author 3, Author 3 and Author 3 needs addressing.

    In this function, it shows the developers tried to work around the author-list issue via the $modify_filter variable. It is, unfortunately, a hack that we can’t easily bypass. You might be able to get around this via reflecting the CoAuthors_Template_Filters class, but that’d be a guerrilla-patch I cannot recommend.

    As of now, I can only recommend forking the plugin and making it fit for purpose. Alternatively, you might be able to get something out of Co-Authors Plus’s plugin-support, but the developers don’t seem to be actively monitoring inquiries.

    I’m sorry I can’t help you further with this. I do hope you find a better alternative or workaround soon. Feel free to keep me posted and ask for pointers along the way. Cheers!

    Thread Starter davereed

    (@davereed)

    I understand. Thanks for the help!

    Plugin Author Sybre Waaijer

    (@cybr)

    Hello!

    We’re going to implement support for the Co-Authors Plus plugin in a future update, where we’ll tackle the problem for everyone using it and TSF. Feel free to contribute to this issue: https://github.com/sybrew/the-seo-framework/issues/509.

    Thread Starter davereed

    (@davereed)

    Amazing! Thanks @cybr!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Co-Authors Plus plugin integration’ is closed to new replies.