WordPress网站地图sitemap.xml提示“This page contains the following errors:”的解决办法,最近一直再折腾站点地图,总算搞的差不多了,竟然发现打开xml文件竟然错误,错误如下:
This page contains the following errors:
error on line 1 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.
解决方法如下: 打开“wordpress”根目录下的“wp-blog-header.php”文件,在
$wp_did_header = true;
代码下加入以下代码:
ob_start()
在以下代码
wp();
下加入以下代码:
ob_end_clean();
最后完整的“wp-blog-header.php”文件因为如以下代码这样:
<?php
/**
* Loads the WordPress environment and template.
*
* @package WordPress
*/if ( ! isset( $wp_did_header ) ) {
$wp_did_header = true;
ob_start();
// Load the WordPress library.
require_once __DIR__ . '/wp-load.php';// Set up the WordPress query.
wp();
ob_end_clean();
// Load the theme template.
require_once ABSPATH . WPINC . '/template-loader.php';}