Skip to content

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

Open
@mchanDev

Description

@mchanDev

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

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions