My sitemap shows xml declaration error

#828417
  • Resolved Hiba
    Rank Math free

    Hello Team,

    My sitemap shows this
    error on line 1 at column 8: XML declaration allowed only at the start of the document.

    I tried removing whitespaces from wp-config.php and functions.php and used the health check plugin to see if there was a theme conflict. Looks like it is. However, I cannot update the theme since its expired. I dont think i can be able to figure this out. So please help me.
    Thanks & Regards
    Hiba

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

    I’m sorry to hear about the issue you are facing with your sitemap showing an XML declaration error. It seems like you have already taken some steps to troubleshoot the problem by checking for white spaces in wp-config.php and functions.php and using the Health Check plugin to identify any theme conflicts.

    Since you mentioned that the theme is expired and you are unable to update it, I recommend adding a filter to your theme’s rank-math.php file as an alternative solution. This can be done by following these steps:

    1. Navigate to WordPress Dashboard → Tools → Theme File Editor (Block Editor) or WordPress Dashboard → Appearance → Theme File Editor (Classic Editor).
    2. Choose the rank-math.php file from the right sidebar.
    3. Add the following filter to the file:
      add_filter( 'rank_math/sitemap/enable_caching', '__return_false');
    4. Click on the Update button to save your changes.

    By adding this filter, you should be able to resolve the error related to the XML declaration in your sitemap. After making these changes, remember to clear your website cache and then check the sitemap again.

    If you encounter any further issues or need additional assistance, please feel free to reach out to our support team directly here, and we will be happy to help you further.

    Thank you for reaching out to us.

    Best regards

    Sources:
    Rank Math Sitemap Issues and Their Fixes » Rank Math
    How to Fix "Incorrect HTTP Header Content-Type" Error in Sitemaps » Rank Math
    Why the Sitemap_Index.xml is Throwing a 404 Error » Rank Math

    Hello,

    Thank you for contacting us and sorry for any inconvenience that might have been caused due to that.

    If you’re not able to find any white space then you can try to follow this guideline to fix the issue: https://wejn.org/stuff/wejnswpwhitespacefix.php.html

    Once done, please try to clear the Sitemap cache by following this video screencast and see if that works for you: https://i.rankmath.com/pipRDp

    Let us know how it goes. Looking forward to helping you.

    Thank you.

    Hiba
    Rank Math free

    Hello Team,

    Its not working. I tried everything. Could you please look into it asap.

    Hello,

    The password for the username that you shared is not correct.

    Can you please verify the same so we can correct the issue on the website and make sure the sitemap loads fine?

    Looking forward to hearing back from you.

    Hiba
    Rank Math free

    I have updated it . Please try to login using the same credentials again.

    Hello,

    We implemented the fix mentioned above on your website and the sitemap is loading fine.

    Having said that, we noticed that the error is coming from the child theme you have on your website so it’s possible that any of the custom functions you are adding to the functions.php file is loading on the sitemap and causing the whitespace to appear.

    For now, the issue is fixed with the tutorial we shared above but when WordPress updates that fix will be removed so you will need to either correct your child theme or add the following line to the index.php file with each update of WordPress:

    
    include("fix_whitespace_error.php");
    

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

    Hiba
    Rank Math free

    thank you so much. I really appraciate it.

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

    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 8 replies - 1 through 8 (of 8 total)

The ticket ‘My sitemap shows xml declaration error’ is closed to new replies.