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 of WordPress core XML Sitemaps and wp_robots indexing control

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.xml automatically for public post types, taxonomies, and author archives; use wp_sitemaps_post_types to exclude custom post types that should not appear in sitemaps.
  • Use the wp_robots filter (introduced in WordPress 5.7, replacing the deprecated wp_no_robots()) to add or adjust <meta name="robots"> directives like noindex or noarchive.
  • Remember that noindex in wp_robots tells crawlers not to index a page, whereas blocking a URL in robots.txt prevents crawlers from seeing that noindex tag.
  • Keep Settings > Reading > Search Engine Visibility unchecked on live sites—if checked, wp_robots_noindex() outputs noindex across 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() (adds noindex on search result pages)
  • wp_robots_noindex_embeds() (adds noindex on oEmbed endpoints)
  • wp_robots_sensitive_page() (adds noindex and noarchive on 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

  1. Check Settings > Reading first. Confirm Discourage search engines from indexing this site is unchecked on production (and checked on staging).
  2. Inspect /wp-sitemap.xml in your browser. Open /wp-sitemap.xml and 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.
  3. Verify <meta name="robots"> on representative pages. View page source on a blog post, a search page (/?s=test), and any custom archive to confirm wp_robots outputs what you expect.
  4. 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_robots snippet 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.txt Disallow to de-index pages that are already in Google. If robots.txt blocks crawling, search bots cannot read the noindex tag from wp_robots and 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—use wp_robots_no_robots on the wp_robots filter 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.

Sources