首页 > CMS建站 > Wordpress > 正文

利用Fix Rss Feeds插件修复WordPress的Feed显示错误

2021-12-03 12:15:07
字体:
来源:转载
供稿:网友

这篇文章主要介绍了利用Fix Rss Feeds插件修复WordPress的Feed显示错误的方法,需要的朋友可以参考下。

今天突然有个网友留言说博客的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,其实只需将这个文件改为:

  1. <?php 
  2. /** 
  3.  * Loads the WordPress environment and template. 
  4.  * 
  5.  * @package WordPress 
  6.  */ 
  7.  
  8. if ( !isset($wp_did_header) ) { 
  9.  $wp_did_header = true; 
  10.   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 
  11.  require_once( dirname(__FILE__) . '/wp-load.php' ); 
  12.   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 
  13.  wp(); 
  14.  require_once( ABSPATH . WPINC . '/template-loader.php' ); 
  15. ?>​ 

就可以了。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表