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 aspostorpage; removing its array entry disables its core sitemap generation.
Key facts
- As of October 2026, the WordPress filter reference documents
wp_sitemaps_post_typesas receiving registered post type objects keyed by their name. - The WordPress core sitemap guide provides an example that excludes
pagewithunset( $post_types['page'] ). - The provider filter reference documents
wp_sitemaps_add_provider, which receives a provider instance and its name before registration. - The post query filter reference documents a separate filter for changing the query arguments used to retrieve sitemap posts.
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.
Related terms
- Where is the built-in WordPress XML sitemap?
- How do I remove user archives from WordPress core sitemaps?
- How do I disable WordPress's core XML sitemap output?
- noindex
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
- WordPress Core, "New XML Sitemaps Functionality in WordPress 5.5", 22 July 2020
- WordPress Developer Resources, "wp_sitemaps_post_types", undated
- WordPress Developer Resources, "WP_Sitemaps_Posts::get_object_subtypes()", undated
- WordPress Developer Resources, "wp_sitemaps_add_provider", undated
- WordPress Developer Resources, "wp_sitemaps_posts_query_args", undated
- Google Search Central, "Block Search indexing with noindex", 10 December 2025
Check how a page reads to answer engines. Open the GEO score analyzer