Error 404 page not found
I was involved in xml sitemap error by wordpress using the SEO plugin by yoast. I was trying to find the solution over the different forums and posts but I couldn’t fix the problem, I felt like banging my head on the wall for not finding the solution to the problem. Finally I discovered the solution to this particular problem and thought to share my experience with all of you who are actually experiencing this annoying situation.
Identified problems and solutions
Many people have looked into it in their own perspective and proposed different solutions. Some people said it is the problem with the SEO by yoast plugin and you have to edit the plugin’s file and provided some additional rewriting codes to put in plugin’s .htaccess file in order to get it fixed and generate sitemap for you. Some people suggested turning on and off the plugin will fix the problem. Some said your theme is poorly coded because of that you are getting that kind of error. Moreover, there were many different opinions and proposed solutions which may have worked well for some people but none for me.
The real problem
In many forums I have came across the argument that the real issue is with one or more of the plugins that you have installed in your wordpress, some of the plugins may create white blank space after opening <?php or the closing tag ?>. So that was the real problem in my case
How did I find the problem?
Once I took this suggestion that the problem is being caused by one of the plugins that I have installed on my wordpress I thought to analyse it thoroughly step by step to find out where the problem lies.
I turned off-deactivated each and every plugin that was installed on my wordpress except SEO by yoast and then generated the sitemap and boom. The sitemap was generated without any problem. This way I figured out that there is nothing wrong with SEO by yoast neither with my worddpress theme coding rather there is definitely something wrong with one of the plugins that I have installed.
Now that I have figured out the real problem is with one of the plugins, in the next step I started reactivating the plugins one by one to figure out which one is causing problem. I activated first plugin and regenerated sitemap it was ok. Then I activated second plugin and regenerated sitemap, all perfect. Then I turned on third Email subscriber plugin and regenerated sitemap, got stuck again that error 404 or line 2 column 6 error was found. Then I deactivated back my email subscriber plugin and checked other plugins that were left to see if anymore plugins have the same problem or not. But none of the others were causing the issue. This way I came to the conclusion that there is only one plugin that has to be fixed.
Now all of the other plugins were activated except my email subscriber and there was no issue in generating sitemaps using SEO by yoast. I went to the email subscriber plugin’s editor to check what’s wrong with the coding keeping that white space and empty line after opening <?php or the closing tag ?> in my mind, I checked the plugin’s code and found the empty space after the closing tag ?> you can see it in the picture below
Then I removed this space by using backspace and it looked like this after removing the space (see picture below)
I also checked the files opening tag <?php to see if there is empty space before or after the tag but it was ok and looked like this (see picture below)
You also have to remove the space if it exists before or after the opening tag <?php which will look like this (see picture)
Just look for opening or closing tags and remove the space by using your computers backspace and update the file. Once you updated the file after removing space you are ready to generate xml sitemap with out any issue.
I believe in most cases the problem would be more or less the same, just follow the steps mentioned above and you will fix your problem. You don’t need to edit your theme’s coding, SEO plugin’s coding or any other suggested fix in this case.
tracking website performance is important ignoring sitemap submissions can cause problemsImage credit: managewp.com