How to Control WordPress Core XML Sitemaps and wp_robots Directives Without Extra Plugins
WordPress ships built-in XML sitemaps at /wp-sitemap.xml and a structured wp_robots meta tag system out of the box. Yet many sites either install a massive SEO suite just to hide one custom post type from the sitemap, or forget that WordPress exposes lightweight core filters to control both sitemaps and <meta name="robots"> tags cleanly. Knowing how wp_sitemaps_post_types and wp_robots work lets you keep search indexing focused on real content with a few lines in a small site plugin.
Editorial illustration: use wp_sitemaps_post_types to prune /wp-sitemap.xml and wp_robots to manage noindex directives cleanly.
Summary
- WordPress core generates
/wp-sitemap.xmlautomatically for public post types, taxonomies, and author archives; usewp_sitemaps_post_typesto exclude custom post types that should not appear in sitemaps. - Use the
wp_robotsfilter (introduced in WordPress 5.7, replacing the deprecatedwp_no_robots()) to add or adjust<meta name="robots">directives likenoindexornoarchive. - Remember that
noindexinwp_robotstells crawlers not to index a page, whereas blocking a URL inrobots.txtprevents crawlers from seeing thatnoindextag. - Keep Settings > Reading > Search Engine Visibility unchecked on live sites—if checked,
wp_robots_noindex()outputsnoindexacross the entire site.
How WordPress core XML sitemaps work
Since WordPress 5.5, WP_Sitemaps_Posts automatically registers public post types into /wp-sitemap.xml. That is helpful for standard posts and pages, yet plugins often register public-facing helper post types (landing-page fragments, testimonials, or internal templates) that you do not want listed as standalone URLs for search engines.
You can exclude a specific post type cleanly with wp_sitemaps_post_types:
add_filter( 'wp_sitemaps_post_types', function ( array $post_types ): array {
unset( $post_types['testimonial'] );
return $post_types;
} );
Similarly, if you run a single-author blog and do not want /wp-sitemap-users-1.xml exposing author archive URLs, you can filter wp_sitemaps_add_provider to skip the users provider.
How wp_robots manages <meta name="robots">
Per the WordPress Developer Reference for wp_robots() and the wp_robots hook, WordPress gathers an associative array of directives on every page load—where boolean true outputs a flag like noindex and string values output pairs like max-image-preview:large.
Core already hooks several sensible defaults onto wp_robots, including:
wp_robots_noindex_search()(addsnoindexon search result pages)wp_robots_noindex_embeds()(addsnoindexon oEmbed endpoints)wp_robots_sensitive_page()(addsnoindexandnoarchiveon login/registration pages)
If you want to add noindex to a specific custom template or tag archive without installing an extra plugin:
add_filter( 'wp_robots', function ( array $robots ): array {
if ( is_tag() ) {
$robots['noindex'] = true;
}
return $robots;
} );
Step-by-step: Audit your WordPress indexing setup
- Check Settings > Reading first. Confirm Discourage search engines from indexing this site is unchecked on production (and checked on staging).
- Inspect
/wp-sitemap.xmlin your browser. Open/wp-sitemap.xmland click through each sub-sitemap (wp-sitemap-posts-post-1.xml,wp-sitemap-taxonomies-...,wp-sitemap-users-1.xml) to verify no thin or internal URLs are listed. - Verify
<meta name="robots">on representative pages. View page source on a blog post, a search page (/?s=test), and any custom archive to confirmwp_robotsoutputs what you expect. - Keep core theme and plugin code clean. If you also customize theme templates or plugin options, review WordPress Block Patterns vs. Template Parts and using
register_setting()safely, and always test changes on staging with a WordPress backup restore rehearsal.
Common mistakes
- Installing an SEO plugin and keeping a conflicting custom
wp_robotssnippet active. If you already use an SEO plugin that manages sitemaps and robots meta tags, pick one source of truth instead of stacking duplicate filters. - Using
robots.txtDisallowto de-index pages that are already in Google. Ifrobots.txtblocks crawling, search bots cannot read thenoindextag fromwp_robotsand may keep the URL in search results with no snippet. - Calling the deprecated
wp_no_robots()function. As noted in the WordPress reference,wp_no_robots()was deprecated in WordPress 5.7—usewp_robots_no_robotson thewp_robotsfilter instead.
Why this matters
Keeping thin tag archives, internal custom post types, and duplicate author pages out of /wp-sitemap.xml focuses search crawlers on your genuinely useful articles without adding database-heavy SEO plugins when you do not need their extra modules.
My Take
If a WordPress site only needs clean XML sitemaps and basic noindex rules on search or thin archives, WordPress core’s wp_sitemaps_* and wp_robots hooks handle it in 15 lines of zero-overhead PHP. Save full SEO plugins for sites where editors actively need per-post social previews, schema builders, or redirect managers.
Conclusion
Inspect /wp-sitemap.xml on your live site, exclude unwanted post types or providers via wp_sitemaps_post_types, use the wp_robots filter for targeted noindex rules, and confirm Search Engine Visibility is configured properly for both staging and production.