Modifying the WordPress sitemap.xml output

Written by James McDonald

February 17, 2022

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.

You May Also Like…

Network speed test host to host

On Ubuntu / Debian apt-get install iperf3 On Windows download it from https://iperf.fr/iperf-download.php#windows Make...