Since WordPress now creates sitemaps automatically since version 5.5, excluding a particular page is not widely known.
The code below will exclude a page from the wp-sitemap.xml
1 2 3 4 5 6 7 8 9 10 11 |
// Remove specific pages function gt_disable_sitemap_specific_page($args, $post_type) { if ('page' !== $post_type) return $args; $args['post__not_in'] = isset($args['post__not_in']) ? $args['post__not_in'] : array(); $args['post__not_in'][] = 221; //locations $args['post__not_in'][] = 261; //blog return $args; } add_filter('wp_sitemaps_posts_query_args', 'gt_disable_sitemap_specific_page', 10, 2); |
1 2 3 4 5 6 7 8 |
// Remove custom specific types function gt_disable_sitemap_post_types($post_types) { unset($post_types['elementor_library']); return $post_types; } add_filter('wp_sitemaps_post_types', 'gt_disable_sitemap_post_types'); |
1 2 3 4 5 6 |
// Remove Users add_filter( 'wp_sitemaps_add_provider', function ($provider, $name) { return ( $name == 'users' ) ? false : $provider; }, 10, 2); |
1 2 3 4 5 6 7 8 9 10 |
// Remove Taxonomies function remove_tax_from_sitemap( $taxonomies ) { unset( $taxonomies['category'] ); //or empty the entire lot (for example if using woocommerce) //$taxonomies=[]; return $taxonomies; } add_filter( 'wp_sitemaps_taxonomies', 'remove_tax_from_sitemap' ); |