Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared hosting Managed WordPress Cloud hosting VPS hosting By reader location Hosting finder
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Blog Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

SEO & AI search · Guide

How to Edit Sitemap in WordPress (Step by Step)

How to Edit Sitemap in WordPress (Step by Step)

Short answer

WordPress sitemaps are generated automatically, so you edit them by changing the rules behind them, not the XML. In Yoast SEO or Rank Math, exclude content types, taxonomies or single posts in the sitemap and search settings. With the core sitemap, use filters such as wp_sitemaps_post_types in a small plugin.

Key takeaways

  • There is no sitemap file to edit, so change the settings or filters that build it.
  • Yoast removes content from the sitemap when you set it not to show in search results.
  • Rank Math has Sitemap Settings with post type toggles and exclude-by-ID fields.
  • Core sitemaps are edited with filters like wp_sitemaps_post_types and wp_sitemaps_add_provider.
  • Clear caches and resubmit the sitemap in Search Console after changes.

How do you edit a sitemap in WordPress?

You edit a WordPress sitemap by changing the settings that build it, such as excluding post types, taxonomies or single posts in Yoast SEO or Rank Math, or by using core sitemap filters in code.

WordPress sitemaps are generated each time they are requested. There is no XML file to open and edit, and any manual change to a saved copy would be lost. You change the rules, and the sitemap updates itself.

Pick your method based on what builds your sitemap:

Sitemap built byWhere you edit it
Yoast SEOYoast settings and the Yoast panel on each post
Rank MathRank Math SEO > Sitemap Settings and the post's Advanced tab
WordPress coreFilters in a small plugin or your theme's functions.php
Other SEO pluginsThat plugin's sitemap settings

Not sure which one you use? Open /sitemap_index.xml and /wp-sitemap.xml on your domain.

The one that loads tells you. Our guide on creating an XML sitemap in WordPress explains each option.

What can you change in a WordPress sitemap?

You can choose which post types, taxonomies, authors and individual URLs appear, and with some plugins you can change how many links each file holds and whether images are listed.

Common edits:

  • Remove tag, category or author archives
  • Remove a custom post type, such as portfolio items or testimonials
  • Exclude single pages, such as thank-you or login pages
  • Turn off the users sitemap
  • Change the number of URLs per sitemap file
  • Add URLs that WordPress does not know about

What you usually cannot do is set priority or change frequency in a useful way. Google has said it ignores those two values, so most plugins no longer offer them.

How do you edit the sitemap in Yoast SEO?

Yoast builds its sitemap from your search appearance settings, so you remove content by setting it not to show in search results, either for a whole content type or for one post.

To remove a whole post type or taxonomy:

  1. Go to Yoast SEO > Settings
  2. Open Content types or Categories & tags
  3. Pick the type, such as Tags
  4. Turn off Show tags in search results
  5. Save

To remove one post or page:

  1. Edit the post
  2. Open the Yoast SEO panel and the Advanced section
  3. Set Allow search engines to show this content in search results? to No
  4. Update the post

Yoast then leaves that URL out of the sitemap and adds a noindex tag to the page. See Yoast's sitemap help page for current screens, and our Yoast SEO settings explained guide for the rest of the options.

How do you edit the sitemap in Rank Math?

Open Rank Math SEO > Sitemap Settings, then use the General tab to exclude posts or terms by ID and the Post Types and Taxonomies tabs to include or remove whole content types.

Step by step:

  1. Go to Rank Math SEO > Sitemap Settings
  2. In General, set links per sitemap and whether to include images
  3. Add IDs to Exclude Posts or Exclude Terms, separated by commas
  4. In Post Types, turn Include in Sitemap on or off for each type
  5. In Taxonomies, do the same for categories, tags and custom taxonomies
  6. Save changes

Setting a single post to noindex in Rank Math's Advanced tab also removes it from the sitemap. Rank Math's sitemap knowledge base article shows each setting. If Rank Math is new to you, start with our Rank Math setup guide.

To find a post ID, hover over the post in the Posts list and read the number after post= in the edit link.

How do you edit the core WordPress sitemap?

Use the core sitemap filters, such as wp_sitemaps_post_types, wp_sitemaps_taxonomies and wp_sitemaps_add_provider, in a small custom plugin or a code snippets plugin.

The core sitemap has no settings screen. It includes public post types, public taxonomies and users with published posts. Changes happen in code.

Put snippets in a site-specific plugin or a snippets plugin rather than your theme's functions.php file, so they survive a theme change. Test on a staging copy first.

The core sitemaps announcement lists all the available hooks.

How do you remove a post type or taxonomy from the core sitemap?

Hook into wp_sitemaps_post_types or wp_sitemaps_taxonomies and unset the type you want to drop from the array that WordPress passes in.

Remove pages and tags:

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

add_filter( 'wp_sitemaps_taxonomies', function ( $taxonomies ) {
    unset( $taxonomies['post_tag'] );
    return $taxonomies;
} );

Use the post type or taxonomy name, not its label. A custom post type called Projects might be registered as project. The wp_sitemaps_post_types reference has the full details.

How do you remove the users sitemap or single posts?

Return false from wp_sitemaps_add_provider for the users provider to drop author URLs, and add post__not_in to wp_sitemaps_posts_query_args to exclude specific posts.

Remove the users sitemap:

add_filter( 'wp_sitemaps_add_provider', function ( $provider, $name ) {
    return ( 'users' === $name ) ? false : $provider;
}, 10, 2 );

Exclude posts by ID:

add_filter( 'wp_sitemaps_posts_query_args', function ( $args, $post_type ) {
    if ( 'post' === $post_type ) {
        $args['post__not_in'] = array( 12, 34 );
    }
    return $args;
}, 10, 2 );

Replace 12 and 34 with your own post IDs. Removing the users sitemap is common on single-author sites, where author archives repeat the main blog.

How do you add custom URLs to a sitemap?

The cleanest way is to register a custom sitemap provider in core, or use your SEO plugin's hooks to add an extra sitemap to the index.

Custom URLs usually come from pages WordPress does not manage, such as a static landing page or a separate app on the same domain.

In core, you extend the WP_Sitemaps_Provider class and register it with wp_register_sitemap_provider(). This is a developer task, and the Make WordPress Core post includes an example.

Yoast and Rank Math both offer filters for adding sitemaps to their index. Check each plugin's developer docs, because filter names and arguments change between versions.

If the pages are not real WordPress content, a separate static sitemap listed in robots.txt is often simpler than forcing them into the plugin sitemap.

Which pages should you remove from your sitemap?

Remove pages you do not want indexed, such as thin archives, thank-you pages, private pages and duplicates, and keep every page you want to rank.

A sitemap should list canonical, indexable URLs that return a 200 status. Google's sitemap guidelines say the same.

Usually keepUsually remove
Posts and pages you want to rankThank-you and order-received pages
Product and product category pagesCart, checkout and account pages
Category archives with real contentThin tag archives
Key landing pagesAuthor archives on single-author sites
Custom post types visitors useInternal post types like testimonials

Be consistent. A URL in the sitemap should not also carry a noindex tag, because that sends mixed signals to search engines.

How do you check the sitemap after editing it?

Open the sitemap again in a private window, confirm the changes show, clear any caches if they do not, then resubmit the sitemap in Google Search Console.

Steps:

  1. Open your sitemap index and the child sitemap you changed
  2. Check the removed URLs are gone and the kept ones remain
  3. If nothing changed, clear your page cache, CDN cache and any object cache
  4. Save Settings > Permalinks once if a sitemap now returns a 404
  5. Resubmit the sitemap in Search Console under Indexing > Sitemaps

Caching is the most common reason edits seem to do nothing. Our guide on clearing cache in WordPress covers plugin, host and CDN caches.

If the sitemap breaks completely after an edit, undo the last change first. Then work through our sitemap troubleshooting guide.

Can you edit a sitemap by hand?

You can edit a downloaded XML copy, but WordPress will not use it unless you upload it as a static file, and a static file goes out of date as soon as content changes.

Hand-edited files make sense only for one-off cases, such as a separate sitemap for non-WordPress pages. For everything else, change the plugin or filter settings so the live sitemap stays accurate.

If you need a copy of the current sitemap for an audit, our guide on exporting a sitemap from WordPress shows how to save it or turn it into a URL list.

Frequently asked questions

How do I remove a page from my WordPress sitemap?

In Yoast SEO or Rank Math, set the page to noindex in its SEO panel, and the plugin drops it from the sitemap. Rank Math can also exclude it by ID in Sitemap Settings. With the core sitemap, use the posts query args filter.

Can I edit the sitemap XML file directly?

Not in a useful way. WordPress builds the sitemap each time it is requested, so there is no stored file to edit. A hand-edited copy only works if you upload it as a static file, and it then goes stale.

Why are my sitemap changes not showing?

Caching is the usual cause. Clear your page cache, CDN cache and object cache, then reload the sitemap in a private window. If a sitemap now shows a 404, save the permalink settings once to refresh the rewrite rules.

Should I remove tags from my sitemap?

Often yes, if your tag archives are thin or repeat category pages. Keep them if tag pages have useful, unique content that you want to rank. Whatever you choose, keep the sitemap and noindex settings consistent.

Do I need to resubmit my sitemap after editing it?

It is not required, because search engines refetch sitemaps on their own. Resubmitting in Google Search Console after a big change can prompt a quicker fetch and shows you any errors in the updated file.

Sources

  1. XML sitemaps in the Yoast SEO plugin Yoast
  2. Configure sitemaps in Rank Math Rank Math
  3. New XML Sitemaps Functionality in WordPress 5.5 Make WordPress Core
  4. wp_sitemaps_post_types WordPress Code Reference
  5. Build and submit a sitemap Google Search Central

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

Written and checked byWPLegible Editorial Team Independent WordPress reviews and guides

Researched from the primary sources listed above and checked against our editorial rules before publishing.