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.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM