Contact Us

If you’re reading this, chances are your sitemap (the XML map of your website) isn’t behaving the way it should. You might see a 404 error, a blank page, or maybe the sitemap isn’t showing all your posts/pages — and worse: your site’s ranking or indexing may be suffering. Don’t worry: I’m going to walk you through why this happens, how to diagnose the problem, and what to do to fix it once and for all.

Let’s dive in.

Why a Sitemap Matters for WordPress (and SEO)

Before we jump into the fixes, let’s emphasise why your sitemap should work perfectly.

A sitemap (specifically an XML sitemap) is like a GPS map for search engines. It helps them discover and index your content efficiently. Without a working sitemap:

  • Search engines may miss new posts/pages or updates.

  • Your crawl budget can be wasted on irrelevant pages.

  • You may get indexing warnings in Google Search Console or other tools.

  • Ultimately, your SEO performance can drop.

In short: an SEO plugin or your theme may generate a sitemap on your WordPress site (for example via Yoast SEO or All in One SEO), but if something is broken, your traffic may suffer.

Common Symptoms: How the “Sitemap Not Working” Error Shows Up

Here are some of the most common issues you’ll encounter:

  • Visiting yourdomain.com/sitemap_index.xml or yourdomain.com/sitemap.xml gives a 404 error.

  • You see a blank page or an XML page with no URLs listed.

  • The sitemap appears in a browser but only shows part of your content (e.g., posts but no pages or vice versa).

  • The sitemap is reachable, but when submitted to Google, you get errors like “Couldn’t fetch”.

  • The sitemap appears to redirect endlessly or points to your homepage instead of the XML.

  • The sitemap page appears as HTML (a normal web page) rather than the XML list of URLs.

We’ll address each of these in the steps below.

1. Quick “Flush and Check” Steps (Low-Hanging Fruit)

Before doing anything complex, run through these quick fixes — many problems are solved here:

a) Flush Permalink Settings

Go to WordPress Dashboard → Settings → Permalinks, and simply click the Save Changes button. Don’t change anything else.
This action flushes the rewrite rules (especially on Apache/Nginx) and often solves 404 sitemap errors.

b) Temporarily Switch to a Default Theme and Disable All Plugins Except Your SEO Plugin

Sometimes a theme or plugin conflict causes the sitemap to malfunction.

  • Switch to a default WordPress theme (like Twenty Twenty-Something).

  • Deactivate all plugins except your SEO plugin (Yoast/All in One/Rank Math).

  • Check the sitemap URL.
    If it works now, you know the culprit is a plugin or your theme.

c) Clear Caches and CDN

If you use a caching plugin or a CDN (like Cloudflare), purge the cache.
Cached dynamic sitemaps can cause 404s, old data, or conflicts.

If the sitemap works after these, congratulations! You solved it. If not, continue to deeper troubleshooting below.

2. Identify the Root Cause: Diagnosing the Problem

In many cases, the root issue falls into one or more of these categories:

  • Permalink / rewrite rules misconfigured (especially on Apache or Nginx).

  • Multiple sitemap generators or conflicts between plugins.

  • Content is set to “noindex” / excluded, so doesn’t appear in sitemap.

  • Server environment (permissions, redirects, subdirectory installation, HTTPS mismatch).

  • Theme or plugin output interfering (headers already sent, whitespace, blank lines).

  • Sitemap URL disabled or changed in plugin settings.

Let’s walk through each of these in more detail.

a) Permalink / Rewrite Rule Problems

If .htaccess (on Apache) or Nginx config doesn’t have the correct rewrite rules, your sitemap may 404. 
For example, for Yoast SEO you may need:

# Yoast SEO – XML Sitemap Rewrite Fix
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^sitemap_index.xml$ /index.php?sitemap=1 [L]
RewriteRule ^([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 [L]
</IfModule>
# END Yoast SEO – XML Sitemap Rewrite Fix

If your WordPress is installed in a subdirectory (e.g., example.com/blog/), adjust accordingly.

On Nginx, similar rewrite rules apply — check your host docs.

b) Conflict: More Than One Sitemap Generator

If you have multiple plugins trying to generate a sitemap (e.g., Yoast + Google XML Sitemaps), they can conflict, freeze, or generate unexpected behaviour.

Fix: Choose one sitemap generator, disable/delete the other(s). Then regenerate/submit.

c) Content Not Showing Because of “Noindex” or Exclusion

Even if your sitemap file loads, it may be missing items. Why? Because the plugin is set to exclude certain content types, taxonomies, posts/pages set to “noindex”, or sitemap is disabled.

Check:

  • In your SEO plugin, check sitemap settings → what post types/taxonomies are included.

  • Ensure posts/pages you expect to see aren’t excluded or set to “noindex”.

  • If it’s a “News sitemap”, check that your content is recent (for news sitemaps).

d) Protocol/URL Mismatch (HTTP vs HTTPS, www vs non-www)

If your site recently moved from HTTP → HTTPS or changed www/non-www, your sitemap may still serve the old URLs, or search engines may perceive a mismatch.

Fix: In Settings → General, check WordPress Address (URL) and Site Address (URL). If mismatched, correct them, then flush permalinks and regenerate sitemap. Also check canonical URL settings in your SEO plugin.

e) Server/Theme/Plugin Output “Headers Already Sent” / Whitespace

If your theme or a plugin has code with extra whitespace (especially before <?php or after ?> in functions.php) or prints output prematurely, it can break the XML sitemap (e.g., blank page, XML declared error like “XML or text declaration not at the start of entity”).

Fix:

  • Check wp-config.php, functions.php for blank lines before <?php or after closing tags.

  • Disable theme/plugins temporarily to test.

  • Or switch to default theme and see if sitemap loads.

f) Server File Permissions / Physical Sitemap vs Dynamic

If your plugin expects to write a sitemap file (rare in modern dynamic-generate style), incorrect permissions may block it. Also, if there is a static sitemap.xml file in root that conflicts with plugin-generated sitemap, you may see odd behaviour.

Fix:

  • Ensure root folder permissions allow the plugin/writing if required (typically 755 for folders, 644 for files).

  • Remove any old static sitemap.xml in root if using a plugin that dynamically generates sitemap_index.xml.

g) CDN or Caching Interfering

If your sitemap is cached and served incorrectly (or treated as a static file) the dynamic logic may fail. Some CDNs may block or cache XML incorrectly.

Fix: Exclude the sitemap URL (e.g., sitemap_index.xml) from caching/CDN, purge cache, test again.

3. Step-by-Step Fix Guide

Here is a structured checklist you can follow. It builds on the diagnosis above and walks you through to a fix.

Step 1: Confirm Your Sitemap URL

  • Try visiting https://yourdomain.com/sitemap_index.xml (for Yoast, Rank Math) or https://yourdomain.com/sitemap.xml (for other plugins).

  • If you get anything other than a valid XML listing of URLs (e.g., 404, blank, redirect to homepage), there’s a problem.

  • Copy the exact URL you see and the HTTP status code (use browser developer tools or curl -I).

Step 2: Flush Permalinks

  • Dashboard → Settings → Permalinks → Save Changes.

  • Then re-visit the sitemap URL. If it now works: done.

  • If not, continue.

Step 3: Disable/Deactivate Plug-Ins (Except SEO Plugin) & Switch Theme

  • Switch to default theme (Twenty Twenty-Two etc.).

  • Deactivate all plugins except your SEO plugin.

  • Visit sitemap again.

    • If it works, there’s a conflict. Reactivate plugins one by one to find culprit.

    • If still fails, continue.

Step 4: Check Sitemap Plugin Settings

In your SEO plugin:

  • Ensure sitemap generation is enabled. (Yoast: SEO → Settings → Features → XML Sitemaps. AIOSEO: SEO → Sitemaps → toggle ON)

  • Check which post types, taxonomies are included. Maybe your content isn’t being included.

  • If you changed the sitemap filename in plugin settings, ensure you request the new URL.

  • If there’s an old static sitemap file, remove it.

Step 5: Inspect .htaccess / Nginx Config (Rewrite Rules)

For Apache (.htaccess):
Open .htaccess at your WordPress root. Ensure it has correct rewrite lines — for example for Yoast:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteRule ^sitemap_index\.xml$ /index.php?sitemap=1 [L]
RewriteRule ^([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

If your site is in a subdirectory (eg /blog/), adjust accordingly.

For Nginx:
You may need to add rewrite rules in your server block. See your hosting or plugin doc.

After editing, reload/restart the server if you have access.

Step 6: Fix Protocol/URL Mismatch

  • Dashboard → Settings → General → check that WordPress Address (URL) and Site Address (URL) use https:// (if your site uses SSL) and correct www/non-www.

  • In SEO plugin, check that sitemap URLs are using the correct protocol/domain.

  • In Google Search Console, ensure the sitemap you submit matches the canonical version of your site.

Step 7: Remove Extra Whitespace or Output Errors

  • In wp-config.php, ensure there is no blank line or space before <?php or after ?>.

  • In your theme’s functions.php, avoid closing PHP tag (?>). If present, ensure nothing after it.

  • Disable poorly coded plugins temporarily.

  • Check your sitemap XML output for errors (view source). If you see unexpected HTML or debug notices, that’s the issue. For example:
    “XML or text declaration not at the start of the entity” means there’s leading whitespace.

Step 8: Exclude Sitemap From Caching/CDN Rules

  • If you use a caching plugin or CDN (e.g., Cloudflare), exclude /sitemap_index.xml, /sitemap.xml from caching or set to “bypass”.

  • Purge server, plugin and browser cache.

  • Re-visit sitemap.

Step 9: Check File Permissions (if needed)

Although many sitemap plugins generate on the fly and don’t require writing to disk, if you have a plugin that writes a static file:

  • Connect via FTP or file manager.

  • Ensure root directory is 755, files 644.

  • If a sitemap.xml exists, delete/rename it and let plugin regenerate.

  • Then test sitemap.

Step 10: Re-submit Sitemap to Google Search Console / Other Tools

Once your sitemap loads correctly:

  • In Google Search Console → Index → Sitemaps → remove old/invalid sitemap entries → Add the correct sitemap URL → Submit.

  • Wait for Google to process.

  • Check for errors or warnings in Search Console.

  • Monitor for indexing status over the next days/weeks.

4. Advanced Scenarios & Edge Cases

Here are a few more uncommon but important scenarios.

a) WordPress in Subdirectory or Multisite Network

If your WordPress installation is in a subdirectory (/blog/), the sitemap URL may differ (e.g., https://domain.com/blog/sitemap_index.xml) and the rewrite rules must reflect the subdirectory path.
Similarly, on a WordPress multisite, sitemaps may behave differently or require extra configuration.

b) Static HTML Sitemap Instead of XML

Some sites generate an HTML sitemap page (for visitors) but submit that to search engines by mistake. Search engines expect XML sitemaps. If they encounter HTML, you’ll see errors like: “Your sitemap appears to be an HTML page.”
Ensure the file you submit is a valid XML sitemap, not a normal webpage.

c) Sitemap Loads but Doesn’t List New Content

If your sitemap loads but you notice your most recent posts/pages aren’t listed:

  • In the SEO plugin, check include/exclude settings (post type/taxonomy).

  • Check your posts/pages aren’t set to “noindex” or excluded from search engines.

  • Clear cache, regenerate sitemap.

  • If using news sitemap (for Google News), ensure content is recent (within last 48 h).

d) Sitemap Redirects to Homepage or a 301 to Non-Sitemap URL

If visiting /sitemap.xml redirects to the homepage or an irrelevant page:

  • There may be an outdated static sitemap in root causing redirect.

  • Plugin rewrite may be incorrect.

  • .htaccess or Nginx config may have redirect rules catching sitemap URL.
    Check for redirect rules or old files, and remove them.

e) Multiple Languages / Multilingual Site

If you run WP in multiple languages (via plugins like WPML, Polylang), make sure your SEO plugin generates a sitemap for each language or the correct one. Some sitemap conflicts may arise when you have language-specific sitemaps plus the default one.

5. Example Code Snippets & Useful Tweaks

Here are some code examples to help you:

i) Force Flush Rewrite Rules on Theme Activation

Add to your theme’s functions.php (temporary):

function mytheme_flush_rewrites_on_activation() {
flush_rewrite_rules();
}
add_action( 'after_switch_theme', 'mytheme_flush_rewrites_on_activation' );

This ensures permalinks are flushed when you switch theme.

ii) Redirect Old Static Sitemap File to Plugin Generated One

If you had a static sitemap.xml and you now use Yoast sitemap, add this to .htaccess:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^sitemap\.xml$ [NC]
RewriteRule ^sitemap\.xml$ /sitemap_index.xml [R=301,L]

This sends old /sitemap.xml requests to /sitemap_index.xml.

iii) Disable Default WordPress Sitemap (if using WP v5.5+)

WordPress core now includes a basic sitemap. If you prefer your SEO plugin’s sitemap, you can disable the built-in one:

add_filter( 'wp_sitemaps_enabled', '__return_false' );

Add this to your theme’s functions.php or a site-specific plugin. Use with caution.

iv) Exclude Custom Post Type from Sitemap via Yoast

If you have a custom post type (say book_reviews) and don’t want it in the sitemap:

add_filter( 'wpseo_sitemap_exclude_post_type', 'exclude_cpt_from_sitemap', 10, 2 );
function exclude_cpt_from_sitemap( $value, $post_type ) {
if ( 'book_reviews' === $post_type ) {
return true;
}
return $value;
}

This prevents that post type from showing in Yoast’s sitemap.

6. Once It’s Fixed: Validate & Monitor

After you’ve applied fixes:

  • Visit your sitemap URL. View source — should show XML with <urlset> etc.

  • Check Search Console → Sitemaps → Last Submitted → Should show “Success”.

  • Monitor indexing of new posts/pages for the next few weeks.

  • Set a reminder (quarterly) to revisit your sitemap and plugin updates.

  • If you add new content types / custom post types / taxonomies, check sitemap settings.

  • Keep backup copies of your .htaccess, theme’s functions.php, etc. in case you need to roll back changes.

7. FAQ Section

Below are frequently asked questions and their answers.

Q1: My sitemap gives a 404 error — what’s the fastest fix?
A: The fastest fix is to flush your permalink settings (Dashboard → Settings → Permalinks → Save Changes), then reassess. If that fails, a plugin/theme conflict or rewrite rule issue is likely.

Q2: I submitted my sitemap to Google Search Console, but it says ‘Couldn’t fetch’ — what should I do?
A: First, ensure the sitemap URL is correct and accessible in your browser (no redirect to homepage). Then check for HTTP status codes, protocol mismatch (HTTP vs HTTPS), and that your domain is verified in Search Console (including exact host: http/https + www/non-www).

Q3: My sitemap loads but some pages or posts are missing — why?
A: Possible reasons:

  • Content is set to “noindex” or excluded.

  • The SEO plugin’s sitemap settings exclude certain post types/taxonomies.

  • There is a caching/CDN issue, or rewrite rules blocking part of sitemap.

  • The content is new and search engines haven’t yet crawled it.
    Check your plugin’s settings and content attributes.

Q4: I use two SEO plugins — could that break my sitemap?
A: Yes. If both generate sitemaps, they can conflict, causing one to override the other or generate errors. It’s best to use only one sitemap generator plugin.

Q5: Does WordPress core generate a sitemap?
A: Yes — since WordPress 5.5+, there is a basic built-in sitemap. But many SEO plugins generate more comprehensive sitemaps. If you’re using an SEO plugin, you may want to disable the built-in one to prevent conflicts. (add_filter( 'wp_sitemaps_enabled', '__return_false' );)

Q6: My site uses Nginx — are there special rules for sitemaps?
A: Yes. Nginx doesn’t use .htaccess; you’ll need to add rewrite rules in your Nginx config. Check your hosting docs and your SEO plugin’s help pages.

Q7: I recently migrated to HTTPS — why is my sitemap still broken?
A: Because your site URL/protocol changed but sitemap URLs or canonical settings still point to HTTP. Ensure WordPress Address and Site Address are https://…, update sitemap settings, flush permalinks, clear caches.

Q8: After fixing the sitemap, should I resubmit to search engines?
A: Yes. After you confirm the sitemap loads properly, submit it via Google Search Console (and other webmaster tools like Bing). This ensures search engines use the correct map going forward.

“If you’re not comfortable dealing with server rewrite rules or your sitemap still doesn’t load, our WordPress support team can perform a full audit in under an hour — get a free quote now.”

Summary

A functioning sitemap is a vital component of your WordPress SEO strategy. While many issues arise from simple mismatches (permalinks, plugin conflicts, caching), some require deeper troubleshooting (rewrite rules, whitespace output, server configuration).

By following the structured diagnosis and step-by-step fix guide above, you’ll be well-positioned to solve the “WordPress sitemap not working” error once and for all. After fixing it, submit to search engines and keep an eye on indexing, so your content gets the visibility it deserves.

If you run into an issue not covered here or need bespoke support (for example on custom post types, multilingual sites or complex server setups), feel free to reach out.

Here’s to your sitemap working properly — and to your site climbing the search results!

Subscribe To Our Newsletter & Get Latest Updates.

Copyright @ 2025 WPThrill.com. All Rights Reserved.