Sitemap.xml Error

#311230
  • Resolved Sean Corey
    Rank Math free

    Hi There,

    When attempting to access our site’s sitemap.xml file, the following error is produced:

    “error on line 1 at column 7: XML declaration allowed only at the start of the document”

    I followed this Rank Math Support Video and installed Health Check and Troubleshooting plugin. The Site Health plugin doesn’t seem to allow us to enable Avada or our Avada Child Theme. Also, Our live website uses a Child Theme, and it seems a Child Theme can’t be tested in troubleshooting mode since only one theme can be installed at a time.

    Do you have further recommendations about how to resolve this issue?

    Note: we followed another Help Article that recommended removing any empty lines from wp-config.php and functions.php….both were done and the issue is still remaining.

    Thanks for your help.

    Best,
    Sean

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.

    Could you please also add the FTP login credentials of your site in the sensitive data section so we can investigate this issue further?

    Looking forward to helping you.

    Thank you.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Hello,

    Thank you for the additional details.

    We have investigated your site and also couldn’t find any whitespace on your wp-config or functions.php file.

    However, to fix this, we have uploaded a new file in the root of your website called whitespacefix.php that’s called on your installation and fixes the whitespace issue on the XML files.

    Then, we included this whitespace fixer file at the beginning of the index.php file:
    include('whitespacefix.php');

    Please check your sitemap now and it’s opening fine. You can clear your website and browser’s cache if it’s still not opening on your end.

    I hope that helps.

    Thank you.

    This is excellent. I can see the sitemap loading now 🙂

    Our themes, plugins, and core WordPress files are under version control using Git. During a WordPress core update, it is possible that index.php will be overwritten.

    Does there happen to be a similar solution that can be done outside of the core wordpress files, to ensure we don’t lose the customizations during an upgrade? Perhaps something on the server-level or within a child theme?

    Many thanks!

    Hello,

    Since we were not able to identify the file that was adding the whitespace, we have applied a global fix. And you don’t need to worry about the changes being overridden after the update. The code will remain in that file even after the update.

    Hope this clarifies your doubts.

    Please don’t hesitate to get in touch in case you need any other assistance.

    Thanks.

    Hi,

    Thank you for your response.

    index.php is part of the WordPress core files and is susceptible to being changed during a WordPress update.

    WordPress codex recommends not to update any core files other than wp-config.php: https://wordpress.org/support/article/editing-files/#editing-files-offline

    Is there a solution similar to the whitspacefix.php that can be added to a plugin or theme to prevent any chance of this change being lost during a WordPress upgrade?

    Thanks for your time.

    Sean

    Hello,

    Because of the way this fix runs it needs to be included in the entry point of your application which in this case is the index.php file on the root of your website.

    As mentioned in the article you shared, you can just take a backup of the file and create a file with notes about the changes for future reference.

    Don’t hesitate to get in touch if you have any other questions.

    Hi There,

    Thanks for your response!

    Can you confirm if index.php gets overwritten during a standard automatic WordPress upgrade?

    Thank you,
    Sean

    Hello,

    To try and prevent the installation from overriding that file you can write-protect the file to see if that helps.

    Plenty of people do this and there are even people who change the name of the index.php file completely.

    Don’t hesitate to get in touch if you have any other questions.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 9 replies - 1 through 9 (of 9 total)

The ticket ‘Sitemap.xml Error’ is closed to new replies.