Modifying the WordPress sitemap.xml output

I use WordPress for customer…

Login

Blog History

I use WordPress for customer websites with the Divi theme and layouts however WordPress is fundamentally a blogging platform so its sitemap.xml contains links to categories and users and you might not want to have those publicised and indexed by Google

The following snippet tells WordPress to skip a couple of the things it normally includes in the sitemap. In this case categories (taxonomies) and the users

Add this to your themes functions.php

add_filter( 'wp_sitemaps_add_provider', function ($provider, $name) {
  return ( in_array( $name, [ 'users', 'taxonomies' ])) ? false : $provider;
}, 10, 2);

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.