テンプレートファイルを変更
feedテンプレートはwp-includes内にあるfeed-atom.php、feed-atom-comments.php、feed-rdf.php、feed-rss2.php、feed-rss2-comments.phpとか。include内のファイルをいじるのは嫌だ。もしWordpressをバージョンアップしたら、上書きされてまうし。
そこで、テーマフォルダに feed-rss2.php を新たに作る。
そして、functions.phpに以下
// rss2 のテンプレートを変更
remove_filter('do_feed_rss2', 'do_feed_rss2', 10);
function custom_feed_rss2() {
load_template( get_template_directory() . '/feed-rss2.php' );
}
add_action('do_feed_rss2', 'custom_feed_rss2', 10, 1);
ちなみに、デフォルトの feed は rss2 、らしい。
全文表示にする
wp-includes内のfeed-rss2.phpは、管理画面の「表示設定>RSS/Atom フィードでの各投稿の表示」で「全文を表示」を選んでいても、抜粋しか表示されないという、怪奇現象。
wp-includes/feed-rss2.php
<?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_feed('rss2') ?>]]></content:encoded>
<?php else : ?>
<content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded>
<?php endif; ?>
<?php endif; ?>
これを以下に変更
my-theme/feed-rss2.php
<?php if (get_option('rss_use_excerpt')) : ?>
<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
<?php else : ?>
<description><![CDATA[<?php the_content_feed('rss2') ?>]]></description>
<content:encoded><![CDATA[<?php the_content_feed('rss2') ?>]]></content:encoded>
<?php endif; ?>
最終更新:2012年10月30日 20:35