How do I exclude a post type from WordPress core sitemaps?

The Citead team, updated

In short. Remove the registered post type name from the wp_sitemaps_post_types array and return the remaining array to exclude that type from core sitemaps.

Definition: Excluding a post type from WordPress core sitemaps means removing that type from the array passed through wp_sitemaps_post_types. A post type is a registered content type, such as post or page; removing its array entry disables its core sitemap generation.

Key facts

Which filter excludes a whole post type?

The core sitemap guide gives this PHP example for excluding the page post type:

add_filter(
    'wp_sitemaps_post_types',
    function( $post_types ) {
        unset( $post_types['page'] );
        return $post_types;
    }
);

The callback removes the array key and returns the remaining post types. For another registered post type, replace page with its registered name. The exclusion applies to that content type as a whole. Keeping the remaining array entries preserves the other eligible types.

The posts provider reference shows the selection that runs before this filter: WordPress obtains public post types, removes attachment, and applies is_post_type_viewable. The filter then receives the resulting array. This explains why an attachment post type is already absent from the default selection.

How do provider and individual-post exclusions differ?

A sitemap provider is the component responsible for retrieving sitemap entries and determining pagination. The core sitemap guide identifies the built-in providers as posts, taxonomies, and users. Its provider-removal example returns false when the provider name is users, while returning the provider unchanged for other names.

Removing the posts provider therefore has a broader scope than removing page from its post types. For one post type, the guide directs developers to wp_sitemaps_post_types. For a taxonomy, meaning a grouping such as tags, it uses wp_sitemaps_taxonomies; its example removes post_tag.

For an individual post, the same guide uses wp_sitemaps_posts_query_args. Its example checks that $post_type equals post, preserves any existing post__not_in array, and appends the post ID to exclude. The query filter reference confirms that the callback receives both the query arguments and the post type name.

How can the result be checked?

The core sitemap guide identifies the sitemap index at this path:

/wp-sitemap.xml

That index lists the site's sitemap pages. After the filter is active, checking the index for the excluded type's sitemap provides a direct check of the generated output. The guide also states that the site visibility setting discouraging search engine indexing disables core sitemaps, which matters when checking a site with no sitemap output.

FAQ

Can I exclude a custom post type?

Yes. The WordPress filter reference defines the array keys as registered post type names. Use the relevant name in the unset expression and return the array.

Does removing a post type from the sitemap prevent Google indexing?

Sitemap exclusion changes the sitemap's contents. Google's noindex documentation describes noindex as the rule for preventing indexing; Google must be able to crawl the page to read that rule.

Which filter disables every core sitemap?

The core sitemap guide documents wp_sitemaps_enabled for disabling sitemap functionality completely. Its example attaches __return_false to that filter.

Sources

  1. WordPress Core, "New XML Sitemaps Functionality in WordPress 5.5", 22 July 2020
  2. WordPress Developer Resources, "wp_sitemaps_post_types", undated
  3. WordPress Developer Resources, "WP_Sitemaps_Posts::get_object_subtypes()", undated
  4. WordPress Developer Resources, "wp_sitemaps_add_provider", undated
  5. WordPress Developer Resources, "wp_sitemaps_posts_query_args", undated
  6. Google Search Central, "Block Search indexing with noindex", 10 December 2025

Check how a page reads to answer engines. Open the GEO score analyzer

Test a page and see what to fix first

The analysis usually takes less than 10 seconds and needs no account.

400,000+ pages scored in the public benchmark