Fix Your Sitemap for WordPress
WordPress sitemap issues come from four plugin options, overlapping defaults, and custom post types that nobody remembers creating. This guide walks through Yoast, Rank Math, All-in-One SEO, and the WordPress core sitemap - and when to use each.
WordPress core added a built-in sitemap at /wp-sitemap.xml in version 5.5 (2020). It's basic but functional. Most real sites still run Yoast, Rank Math, or All-in-One SEO because those plugins expose per-type exclusions, image sitemaps, and integration with the rest of the SEO config. If you have two of them installed at once, you'll have conflicting sitemaps and Google will crawl both. Pick one.
Saw a WP agency site with 180 real blog posts. Yoast sitemap showed 4,200 URLs. The reason: an old "Documentation" custom post type from a plugin they'd deactivated (but not deleted) still had 3,900 orphaned posts in the database, and Yoast was happily listing them. Deleting the post type via WP-CLI cleared it instantly.
Plugin comparison
- WordPress core (
/wp-sitemap.xml): good default for brochure sites. No image entries. No per-type exclusions without a code filter. - Yoast SEO (
/sitemap_index.xml): per-type toggles in Search Appearance, image sitemap integrated, solid for non-technical users. - Rank Math (
/sitemap_index.xml): better UI, more granular controls, stronger for technical SEOs. Free tier covers most use cases. - All-in-One SEO (
/sitemap.xml): similar feature set to Yoast, good for WooCommerce stores thanks to dedicated product sitemap support.
Common WordPress Sitemap Issues
- Two SEO plugins both emitting sitemaps, double-submitted to GSC
- Tag and category archives included for taxonomies with 2-3 posts each (thin content)
- Author archives listing contributors who never published
- Attachment pages (
/attachment/image-name/) indexable by default - Orphaned custom post types from deactivated plugins
- WooCommerce product variations,
?orderby=, and?filter_URLs appearing in search - Multisite networks with each subsite's sitemap submitted to the wrong GSC property
- Yoast sitemap cache not rebuilding after bulk imports
Attachment pages - the silent bloater
Every image uploaded to WordPress gets its own URL like /attachment/photo-name/. By default these are indexable, and on a site with years of media uploads you can have thousands of them. Yoast disables them via: SEO > Search Appearance > Media > "Redirect attachment URLs to the attachment itself" = Yes. Rank Math: Titles & Meta > Media > Redirect Attachments to Parent = On.
Excluding custom post types
// Core sitemap: exclude a post type
add_filter('wp_sitemaps_post_types', function ($post_types) {
unset($post_types['product_variation']);
unset($post_types['acf-field']);
return $post_types;
});
// Core sitemap: exclude specific posts
add_filter('wp_sitemaps_posts_query_args', function ($args, $post_type) {
if ($post_type === 'post') {
$args['post__not_in'] = [123, 456];
}
return $args;
}, 10, 2);
// Yoast: exclude a post type entirely
add_filter('wpseo_sitemap_exclude_post_type', function ($excluded, $post_type) {
if ($post_type === 'attachment') return true;
return $excluded;
}, 10, 2);WooCommerce quirks
WooCommerce registers product_variation as a public post type, which can leak variation URLs into core and some plugin sitemaps. Also: ?orderby=popularity, ?filter_color=red, and /page/2/ on shop archives. Add robots.txt rules for the parameters, and use the filter above to drop product_variation.
Multisite
On a multisite network, each site has its own sitemap. Subdomain multisites: site1.example.com/sitemap_index.xml. Subdirectory: example.com/site1/sitemap_index.xml. Each subsite should be a separate property in GSC. Don't build a "network sitemap" that combines them - GSC treats them as separate domains anyway, and you lose per-site coverage data.
Step-by-Step Fix Guide
- Pick one SEO plugin (Yoast, Rank Math, or AIOSEO). Deactivate and delete any others
- In that plugin, toggle off taxonomy archives with thin content (tags with <5 posts)
- Disable author archives if only 1-2 authors have published
- Turn on "Redirect attachment URLs to the attachment itself"
- Audit custom post types via WP-CLI:
wp post-type list. Remove orphans. - For WooCommerce, exclude
product_variationand block filter parameters in robots.txt - Clear Yoast/Rank Math sitemap cache (Tools > Clear sitemap cache or
wp rewrite flush) - Verify with
curl https://yoursite.com/sitemap_index.xmland spot-check URLs - Submit the sitemap index (not individual sub-sitemaps) to Google Search Console