I cannot replicate such an issue on my site. I don’t actually have over 2000 posts of any type, but I’ve reduced the posts per page count so I can get multiple sitemap pages. I don’t think it’s a core WP issue.
Your theme or one of your plugins is corrupting the query used to compile sitemap pages. It’s pretty much just a normal WP_Query
posts query that code can easily alter, intentionally or not. This often happens when plugins use the default “paged” query var for their own purposes.
Eliminate possible sources of this corruption. Deactivate all plugins and switch to a twenty* default theme. Restore whatever module has added your news post type. Check your sitemap pages again. If there is still an issue, the module adding the news post type is the one responsible. If the issue is gone, reactivate your remaining modules, one at a time, until the issue returns.
Seek help through the dedicated support forum of the responsible module.
Thread Starter
arey
(@arey)
Thanks for your reply. I did as you advised.
Duplicate content in wp-sitemap-posts-news-1.xml and
/wp-sitemap-posts-news-2.xml is most likely related to using the Polylang plugin.
But even after disabling all plugins and installing the default WordPress theme, the default WordPress XML sitemap wp-sitemap.xml does not work correctly. If this is not the first xml file (NOT equal to 1), but for example 2, 3 or 4, then /wp-sitemap-posts-news-2.xml is loaded, but a 404 error is visible in the console. Search engines also cannot access such XML sitemap (2, 3, 4…)
Screenshot – https://pastenow.ru/e1de5091765f92b2091dbd363066c875
Can you please tell me how to fix this problem?`
/wp-sitemap-posts-news-2.xml is loaded, but a 404 error is visible
So you can see the proper content, but the request returns a 404 status? That is very strange, This would indicate the wrong response header is being sent even though the request otherwise works. Somehow the query is being corrupted in a way I cannot explain. Since I cannot replicate this behavior on a my site, I can only guess at what might be the problem.
We’ve ruled out plugins and themes. There could still be a must-use plugin involved. It can be deactivated by renaming the /mu-plugins/ folder (in /wp-content/) If there is no such folder, you have no must-use plugins.
There could be something odd about the server configuration. A rule in .htaccess could cause problems for example. Or modSecurity could be interfering, although it normally returns 403 status, not 404.
It’s possible core WP became corrupted somehow, perhaps due to a faulty update. If you haven’t done so yet, update to the latest version. If you’re already there, try the Re-install button on the updates screen. TBH, I don’t fully trust the re-install button. For greater confidence I recommend doing a manual “update”, even though it’s really to the same version (from a freshly downloaded .zip).
Thread Starter
arey
(@arey)
The problem is most likely in WordPress – wp-sitemap.xml did not work correctly if there were a lot of posts (split sitemap.xml into several files).
Plugin Installation
https://wordpress.org/plugins/xml-sitemaps-manager/ and enabling the “Apply bug fixes and optimizations” option fixed the problem.
I’m glad it’s fixed. I guess there’s no simple way to know which specific fix or optimization actually solved the problem.
When you have a spare moment, it’d be awesome if you left a review for the plugin. I don’t have any relation to the plugin, but it helps the WP community overall to review plugins that do good things for us.