# Exclude Content Types From the XML Sitemap

> Removes chosen post types and taxonomies (tags by default) and the users list from the built-in wp-sitemap.xml.

- Type: PHP
- Runs: Run everywhere
- Category: [SEO](https://wpide.com/library/category/seo/)
- Tags: seo, sitemap
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/exclude-from-sitemaps/

## Code

```php
add_filter( 'wp_sitemaps_post_types', function ( $post_types ) {
    // Post type names to leave out, for example 'page'.
    foreach ( array() as $name ) {
        unset( $post_types[ $name ] );
    }

    return $post_types;
} );

add_filter( 'wp_sitemaps_taxonomies', function ( $taxonomies ) {
    unset( $taxonomies['post_tag'], $taxonomies['post_format'] );

    return $taxonomies;
} );

add_filter( 'wp_sitemaps_add_provider', function ( $provider, $name ) {
    return 'users' === $name ? false : $provider;
}, 10, 2 );
```

## Notes

Add post type names to the empty array to exclude them.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Exclude Content Types From the XML Sitemap" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
