利用Fix Rss Feeds插件修复WordPress的Feed显示错误
利用Fix Rss Feeds插件修复WordPress的Feed显示错误
发布时间:2016-12-29 来源:查字典编辑
摘要:今天突然有个网友留言说博客的Feed挂了,症状如下:Chrome直接打开订阅页面显示如下:Thispagecontainsthefollow...

今天突然有个网友留言说博客的Feed挂了,症状如下:

Chrome直接打开订阅页面显示如下:

This page contains the following errors: error on line 1 at column 1: Document is empty Below is a rendering of the page up to the first error.

FeedDemon提示:此Feed包含错误。

添加后也没什么影响,能正常使用。

鲜果阅读器也可阅读,但是没有获取到最新的文章。

用IE试了下,显示“文档顶层存在无效内容。”

查看源代码发现是能看到HTML格式解析后的内容,这说明WordPress的Feed输出是没有问题的,出问题的在于某个文件的格式。不过要找到是哪个文件出问题就比较难了。网上给出的解决方法大致都是这样的:

检测上、下是否有多余的回车、换行符号

1、检测 wp-config.php 文件,查看PHP主体之外的代码有无回车符;

2、同上,检测 wp-rss2.php,wp-atom.php文件,如果最近没修改过,可略过;

3、同上,检测 functions.php 文件;

4、注意 feed是有缓存的,在修改完成之后,发一篇文章,使WP程序重建feed,从而查看效果;

5、若仍然有错,可以尝试暂时关闭所有插件,更换主题等逐个排除。

把上述文件都修改了个遍,还是没有头绪。。于是装了个插件“Fix Rss Feeds”,启用后修复一下就搞定了。而且修复之后把插件删了也不会反弹~

研究了下这个插件,似乎只是修改了WordPress根目录下的wp-blog-header.php,其实只需将这个文件改为:

<?php /** * Loads the WordPress environment and template. * * @package WordPress */ if ( !isset($wp_did_header) ) { $wp_did_header = true; ob_start(); //2010-09-18 gofunnow.com added, it will Fix rss feed error "Error on line 2: The processing instruction target matching "[xX][mM][lL]" is not allowed." while burn feed from feedburner.com require_once( dirname(__FILE__) . '/wp-load.php' ); ob_end_clean(); //2010-09-18 gofunnow.com added, it will Fix rss feed error "Error on line 2: The processing instruction target matching "[xX][mM][lL]" is not allowed." while burn feed from feedburner.com wp(); require_once( ABSPATH . WPINC . '/template-loader.php' ); } ?>​

就可以了。

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新php教程学习
热门php教程学习
编程开发子分类