Skip to content

Conversation

justinmaurerdotdev
Copy link

Description

Fixes #1092

Quoting the Issue I created (above)

CAP uses this filter, wpseo_replacements, to fix Yoast's usage of the %%name%% placeholder. However, this filter is also during the rendering of the page <title>. This means that when the page is an author archive, the author's name is being substituted with the display names of all of the authors of the top post on the page.

It turns out that in this case, the $args->ID found in the filter_author_name_variable() method (and passed to get_coauthors()) is just defaulting to the first post in the loop, because that's what is set in $GLOBALS['post'] (the default when get_the_ID() is called with no arguments). This issue seems totally fixed by the addition of is_single() in the logic for whether to do the replacement.

I am assuming that this filter is intended to fix the author name strings for the schema/meta on individual posts (things that actually have co-authors), and that this fix won't impact anything negatively, but please chime in if you can think of some reason why this filter would be needed on an archive.

Steps to Test

I'm not 100% clear on how to write any automated tests for this sort of third party integration in this repo, so if those are needed, I would appreciate some advice on setting that up. But, you can see the issue in an archived version of one of our pages. Were this functioning properly, it would only show the one name in the <title>.

… <title> on author archives (via Yoast's Title_Presenter).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CAP causing Yoast to render the wrong titles for author archives

1 participant