WordPressのRSSにアイキャッチ画像入れる方法。

WordPressのRSSにアイキャッチ画像入れる方法。

RSSに画像が入っていないとFeedlyなどのRSSリーダーに適切なサムネイルが入らないことがあります。そこでちゃんとRSSにサムネイルを入れる方法です。

WordPress-love

WordPressのRSSに画像を入れる方法

サンプルソース

function rss_post_thumbnail($content) {
global $post;
if(has_post_thumbnail($post->ID)) {
$content = '

' . get_the_post_thumbnail($post->ID) . '

' . $content; } return $content; } add_filter('the_excerpt_rss', 'rss_post_thumbnail'); add_filter('the_content_feed', 'rss_post_thumbnail');

もし、RSSに画像がちゃんと入っていないとクリック率も下がりますので、ちゃんと入れておいたほうがいいですよ。

attrip

attrip

考えたことを、記事・AI・音楽に変えて発信しています。

盆栽、音楽、ブログ運営、日々の試行錯誤について書いています。

2010年から発信中