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

allow_indexing_guest_author_archive for Yoast compatibility ignores Show author archives in search results setting in Yoast #1059

Open
mchanDev opened this issue Sep 11, 2024 · 0 comments

Comments

@mchanDev
Copy link

The code block here, ignores the Yoast settings that disable search indexing of Author archives.

* Co-Authors Plus and Yoast are incompatible where the author archives for guest authors are output as noindex.
* This filter will determine if we're on an author archive and reset the robots.txt string properly.
*
* See https://github.com/Yoast/wordpress-seo/issues/9147.
*
* @param string $robots The meta robots directives to be echoed.
* @param Indexable_Presentation $presentation The presentation of an indexable.
*/
public static function allow_indexing_guest_author_archive( $robots, $presentation ) {
if ( ! is_author() ) {
return $robots;
}
if ( ! is_a( $presentation, Indexable_Author_Archive_Presentation::class ) ) {
return $robots;
}
$post_type = get_post_type( get_queried_object_id() );
if ( 'guest-author' !== $post_type ) {
return $robots;
}
/*
* If this is a guest author archive and hasn't manually been set to noindex,
* make sure the robots.txt string is set properly.
*/
if ( empty( $presentation->model->is_robots_noindex ) || 0 === (int) $presentation->model->is_robots_noindex ) {
if ( ! is_array( $robots ) ) {
$robots = [];
}
$robots['index'] = 'index';
$robots['follow'] = 'follow';
}
return $robots;
}

The relevant option in Yoast appears to be used here $this->options->get( 'noindex-author-wpseo', false )
https://github.com/Yoast/wordpress-seo/blob/0a1623546fed6266f466035dcf63d41209542060/src/presentations/indexable-author-archive-presentation.php#L121-L124

I believe adding the same options check should address this

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

No branches or pull requests

1 participant