SEO PHP Beginner

Remove Users From the WordPress Sitemap

Stop WordPress listing author archive URLs, and with them your usernames, in its built-in XML sitemap.

Tested on WordPress 7.1 PHP 8.3 No plugin needed Updated
functions.php 3 lines
add_filter( 'wp_sitemaps_add_provider', function ( $provider, string $name ) {
	return 'users' === $name ? false : $provider;
}, 10, 2 );

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

WordPress’s built-in sitemap at /wp-sitemap.xml includes a list of every author’s archive URL. On most sites those pages have little value for search, and the URLs reveal usernames. This snippet removes the users sitemap.

How it works

Core sitemaps are built from providers: posts, taxonomies and users. wp_sitemaps_add_provider runs as each one is registered. Returning false for users removes it from the sitemap index and makes /wp-sitemap-users-1.xml return a 404.

Things to watch

  • Author archive pages still exist. Use the “Disable Author Archives” snippet if you want them gone completely.
  • SEO plugins replace core sitemaps with their own and have a setting for this.

How to test it

Open yoursite.com/wp-sitemap.xml. There should be no users sitemap in the list.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only