作者:李笑来 来源:Pure Pleasure - Reborn   酷勤网收集 2008-08-06

摘要
  上网搜索了一下,在美女Lisa Sabin Wilson的网站上找到个解决方案,但好像在我这里不管用。想了想,修改了一下/wp-includes/目录里面的feed-rss2.php文件,搞定!其实就是修改一下feed-rss2.php文件中的while loop中的内容

前两天,异想天开,然后给自己的blog上加了个“涂鸦”分类,把临时想到的乱七八糟的东西放在里面。结果收到了“退订威胁”。其实,当天我就注意到了,只是没想到如何解决。威胁的力量是无穷的……当然,想想tiny的“微尘程序员网站”上布满了垃圾,也确实非常内疚。

上网搜索了一下,在美女Lisa Sabin Wilson的网站上找到个解决方案,但好像在我这里不管用。想了想,修改了一下/wp-includes/目录里面的feed-rss2.php文件,搞定!

其实就是修改一下feed-rss2.php文件中的while loop中的内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
	<?php while( have_posts()) : the_post(); ?>
	<?php if (in_category(36)) :?>
		 <!-- exclude category id=36 from feed rss2 -->
	<?php else : ?>
	<item>
		<title><?php the_title_rss() ?></title>
		<link><?php the_permalink_rss() ?></link>
		<comments><?php comments_link(); ?></comments>
		<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
		<dc:creator><?php the_author() ?></dc:creator>
		<?php the_category_rss() ?>
 
		<guid isPermaLink="false"><?php the_guid(); ?></guid>
<?php if (get_option('rss_use_excerpt')) : ?>
		<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
<?php else : ?>
		<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
	<?php if ( strlen( $post->post_content ) > 0 ) : ?>
		<content:encoded><![CDATA[<?php the_content() ?>]]></content:encoded>
	<?php else : ?>
		<content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded>
	<?php endif; ?>
<?php endif; ?>
		<wfw:commentRss><?php echo get_post_comments_feed_link(); ?></wfw:commentRss>
<?php rss_enclosure(); ?>
	<?php do_action('rss2_item'); ?>
	</item>
	<?php endif; ?>		 <!-- exclude category id=36 from feed rss2 -->
	<?php endwhile; ?>

其中的2~4行,以及28行是后填进去的。从此之后,我的rss 2.0 feed输出的时候,不再输出“涂鸦”这个分类里的文章。

至于其它类型的feed,原理应该一样,可以分别修改wp-includes目录中的以下文件:

  • feed.php
  • feed-atom.php
  • feed-atom-comments.php
  • feed-rdf.php
  • feed-rss.php
  • feed-rss2.php
  • feed-rss2-comments.php

来自:http://www.xiaolai.net/index.php/archives/701.html

分类: 站长经验 Web开发 网页设计

上一篇:使用自定义页面作为WordPress首页   下一篇:5款Wordpress联系表单插件/Contact Form