Sitemap Error : XML declaration allowed only at the start of the document解决方法

  今天ytkah的客户反馈说他的xml网站地图有问题,提示Sitemap Error : XML declaration allowed only at the start of the document,这个很大的可能是wp-config.php或主题function.php文件中有多余的空格/空行,打开他的function.php看了一下,发现在最后加了一些定义

<?php
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
?>

  这个是另起了一个<?php ?>,试着把它去掉,然后把remove定义放到前面的封装里,保存上传覆盖,更新缓存,更新cdn,再访问一下xml网站地图不会出现前面的错误提示了。

  参考资料However, the cause most often is an empty line at the beginning (before the <?php line) or end of the wp-config.php or functions.php file. If there is no empty line in these files, we highly recommend running a conflict check to identify what outputs the empty whitespace. You may also need to clear your caching from your plugins/theme/CDN such as Cloudflare/server caching etc.

原文地址:https://www.cnblogs.com/ytkah/p/11647056.html