Make WordPress Core

Opened 3 months ago

Last modified 3 months ago

#57816 new defect (bug)

WordPress shows author archive in sitemap even if there are no posts

Reported by: zodiac1978's profile zodiac1978 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.5
Component: Sitemaps Keywords: needs-patch
Focuses: Cc:


It looks like this should be avoided: If there are no posts in the WP installation (only pages), the wp-sitemap.xml still contains the author archive. And if you follow the link, you get a 404 error.

This couldn't make sense for SEO ...

Change History (2)

#1 @amisiewicz
3 months ago

Yes whenever page is added, author archive is present in the sitemap.xml

Is this a bug, I don't know

About 404 error, I think it depends on a theme (that was not an issue in my local wordpress-develop installation)

If this is a bug, I'm willing to provide a patch (just not sure about that)

For now, I'm leaving the code to possibly fix this as a use of a filter

add_filter( 'wp_sitemaps_users_query_args', function( $args ) {

        if ( ( $key = array_search( 'page', $args['has_published_posts'] ) ) !== false ) {
                unset( $args['has_published_posts'][ $key ] );
        return $args;

}, 10, 1 );
Last edited 3 months ago by amisiewicz (previous) (diff)

#2 @zodiac1978
3 months ago

Found this:

Should only be generated for those authors with at least 1 published post.


Looks like this is a bug then.

Note: See TracTickets for help on using tickets.