Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

%%name%% snippet variable not outputting the author name when the first post on the author archive page contains coauthor post added via 'Co-Authors Plus' plugin #21871

Open
6 of 11 tasks
MastaBaba opened this issue Nov 27, 2024 · 4 comments

Comments

@MastaBaba
Copy link

  • I've read and understood the contribution guidelines.
  • I've searched for any related issues and avoided creating a duplicate issue.

Please give us a description of what happened

I use Co-Authors Plus.

The author archives show an incorrect page title. This, because the %name variable for some reason doesn’t use the name of the author, but uses the list of authors associated with the first article in the archive in question.

So, instead of “Mr. X, Author at My Website”, when the first article in the list was authored by “Mr. X” and “Mr. Y”, the title of the archive for both Mr. X and Mr. Y is “Mr. X, Mr. Y, Author at My Website”.

Removing any value for the “SEO title” for the “Search appearance” of the Author archives reverts to the problem above. Only the %name variable outputs the author name, and, when used, picks up the list of names of the first article in the archive.

In my example, both Mr. X and Mr. Y are users, not guest authors. And the incorrect title is showing in the author archives for both users.

So, the titles of the author archive for the user Mr. X, and the title for the author archive for Mr. Y are both “Mr. X, Mr. Y, Author at My Website””.
In both cases, the author archive is requested, so something like /author/mrx and /author/mry.

Therefore, it’s very clear what author should be named in the title.

Started this bug report here: https://wordpress.org/support/topic/author-archives-not-having-the-correct-title/

To Reproduce

Step-by-step reproduction instructions

  1. Install YOAST and Co-Authors Plus.
  2. Create 2 users.
  3. Create a post with both users as authors.
  4. Publish the post.
  5. Check the author archives for either author.

Expected results

  1. The page title is something like "Mr. X, Author of My Website".

Actual results

  1. The page title is "Mr. X, Mr. Y, Author of My Website".

Screenshots, screen recording, code snippet

If possible, please provide a screenshot, a screen recording or a code snippet which demonstrates the bug.

Technical info

  • If relevant, which editor is affected (or editors):
  • Block Editor
  • Gutenberg Editor
  • Elementor Editor
  • Classic Editor
  • Other:
  • Which browser is affected (or browsers):
  • Chrome
  • Firefox
  • Safari
  • Other: All

Used versions

  • Device you are using: Any
  • Operating system: Any
  • PHP version: 8.1
  • WordPress version: 6.7.1
  • WordPress Theme: Custom
  • Yoast SEO version: 23.9
  • Gutenberg plugin version:
  • Elementor plugin version:
  • Classic Editor plugin version:
  • Relevant plugins in case of a bug: Co-Authors Plus
@josevarghese
Copy link
Contributor

Hi @MastaBaba

Thanks for using the Yoast SEO plugin and for reporting the issue. We apologize for the trouble you are experiencing with snippet variable %%name%% not outputting as expected when the post is added with the co-authors. I am able to replicate this issue at my end.

Workaround
As this occurs when the first post on the author archive page contains the co-authors, you can try out one of the workarounds to fix the author archive title for this case:

a) via the User edit page:

  1. Edit the author profile page
  2. Under the heading Yoast SEO settings >, you can add the "Title to use for Author page" to override this.

b) Via code using the filter wpseo_title to change the SEO title output for author pages
Note: For your site's health and safety, we recommend creating regular backups of your site and database before testing the code. This is especially important before installing, updating, or removing plugins. Learn more about the benefits of regular backups.

add_filter( 'wpseo_title', 'custom_author_archive_title', 10, 1 );

function custom_author_archive_title( $title ) {
    if ( is_author() ) {
        $author_name = get_queried_object()->display_name;
        $title = sprintf( '%s - Author Archive', $author_name );
    }
    return $title;
}

You can change the Author Archive to something like Author Archive - Your sitename or something you prefer to have.

What's next?
Our product team will assess the severity of this problem in relation to other open bug reports and new features. Based on their assessment, the bug report will be given a priority level. Our developers work on the highest priority issues first. Unfortunately, this means we cannot give you an estimate of when they'll start working on your report.

Please don't hesitate to contact us back if you have further concerns.

@josevarghese josevarghese changed the title Author archives not having the correct title %%name%% snippet variable not outputting correctly when the first post on the author archive page contains coauthor added via 'Co-Authors Plus' plugin Dec 2, 2024
@josevarghese josevarghese changed the title %%name%% snippet variable not outputting correctly when the first post on the author archive page contains coauthor added via 'Co-Authors Plus' plugin %%name%% snippet variable not outputting the author name when the first post on the author archive page contains coauthor post added via 'Co-Authors Plus' plugin Dec 2, 2024
@MastaBaba
Copy link
Author

Thanks @josevarghese,

The first option isn't very sustainable, as this problem crops up for the majority of our few hundred authors.

The second option works. Seems to me like updating YOAST's code on your end would be trivial, no?

Thanks again.

@josevarghese
Copy link
Contributor

Thanks for the confirmation @MastaBaba !

Yes, this issue has been escalated to the development team. As mentioned, our developers work on the highest-priority issues first. Unfortunately, this means I cannot give you an estimate of when they'll start working on this.

Thanks for understanding.

@josevarghese
Copy link
Contributor

Internal Slack conversation: https://yoast.slack.com/archives/C01NCRHHN30/p1733130245603449

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants