解决WordPress插件生成XML Sitemap站点地图报错
- Wordpress
- 2023-05-08
- 361热度
- 0评论
WordPress免费主题Document让我又有重新写博客的动力,但是今天在生成XML Sitemap时报错,我用Disable WP Sitemaps插件禁用WP自带的XML站点地图,安装的XML Sitemap Generator for Google插件,其实不管哪个插件,只要生成地图就会提示:
This page contains the following errors:
error on line 3 at column 6: XML declaration allowed only at the start of the document
Below is a rendering of the page up to the first error.
查看网页源代码,头部会空出两行:
<!DOCTYPE HTML>
<html lang="zh-CN" xmlns="http://www.w3.org/1999/html" class="personal">
解决方法
找到根目录下的wp-blog-header.php文件,将文件内容改成如下代码:
<?php
/** * Loads the WordPress environment and template. * * @package WordPress */
if ( !isset($wp_did_header) ) {
$wp_did_header = true; ob_start();
require_once( dirname(__FILE__) . '/wp-load.php' ); ob_end_clean();
wp(); require_once( ABSPATH . WPINC . '/template-loader.php' );
}
修改保存后FTP上传覆盖,刷新站点地图显示正常,查看网页源代码的空出部分也不见了。
WordPress免费主题Document
作者网站
https://nicen.cn/1552.html开源地址
Github:https://github.com/friend-nicen/theme-document