Appearance -> Themes<\/em>. Hover over Twenty Twenty and click \"Activate\".<\/p>\n\n\n\nRefresh the sitemap. The sitemap should be working by now.<\/p>\n\n\n\n
If you are using a child theme, just activate the parent theme.<\/p>\n\n\n\n
Refresh the sitemap. If it's still working, the problem is in the child theme. If it's not, you'll have to look into the parent theme.<\/p>\n\n\n\n
Start by looking at the functions.php<\/em> file.<\/p>\n\n\n\nYou're looking for a blank line above the <?php<\/em> line, which should start the file.<\/p>\n\n\n\nIt's fine for there to be anything else on the same line after <?php<\/em>, but nothing should be before it on that line, nor should there be anything above it.<\/p>\n\n\n\nIf you find what you think is the problem, fix it, save it and refresh the sitemap.<\/p>\n\n\n\n
Also look through functions.php<\/em> for any theme files that are included or required. One of those was the problem I encountered today.<\/p>\n\n\n\nIncluding or requiring a file will look like one of these lines:<\/p>\n\n\n\n
include (get_template_directory() . '\/whatever.php');\nrequire (get_template_directory() . '\/however.php');\ninclude_once (get_template_directory() . '\/whomever.php');\nrequire_once (get_template_directory() . '\/wherever.php');<\/code><\/pre>\n\n\n\nThe key part is the first statement of each of those lines. It just tells WordPress to refer to those other files.<\/p>\n\n\n\n
Try commenting out those lines by adding a double slash to the start of the line like so:<\/p>\n\n\n\n
\/\/include_once (get_template_directory() . '\/whomever.php');<\/code><\/pre>\n\n\n\nSave and refresh the sitemap.<\/p>\n\n\n\n
You might get some errors, because other parts of the functions.php<\/em> are relying on those includes and requires.<\/p>\n\n\n\nIf those errors are affecting the sitemap display (other than the declaration error), try to comment out all the add_action<\/em> and add_filter<\/em> lines (just use the bulk find and replace in your text editor).<\/p>\n\n\n\nHopefully by this stage you should know which file is causing the issue.<\/p>\n\n\n\n
If there is no extra space at the top of that file, check the end of the file. I've not found that extra space at the end of php files has caused this type of issue, but in figuring out this issue today I read that sometimes this causes the error.<\/p>\n\n\n\n
Apply the fix to the live website<\/h2>\n\n\n\n Once you have figured out how to fix the problem on the copy of the website, go into the live website and apply that fix. You might need to edit the files in cPanel<\/a> or FTP<\/a>.<\/p>\n\n\n\nOnce you've applied the fix (clear the cache if you have one active), refresh the sitemap. Hopefully it's now working fine and you can resubmit it to Google.<\/p>\n\n\n\n
If the sitemap is still not working, check whether you have any Must-Use<\/em> or Drop-in<\/em> plugins on the website:<\/p>\n\n\n\n <\/figure><\/div>\n\n\n\nIf you do, you will probably have to raise the issue with your host as it may be an issue with one of their automatically installed plugins.<\/p>\n","protected":false},"excerpt":{"rendered":"
I was working on a new client’s website today, checked sitemap_index.xml and saw this error: The XML sitemap was rendered using the Yoast SEO plugin. This is what it should look like: Viewing the source of the page, the error was being caused by an errant space at the top of the XML sitemap. The<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"yoast_head":"\n
How To Fix Yoast Sitemap XML Declaration Error<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n