WordPressが発行するRSSフィードは、デフォルトではアイキャチ画像が表示されない。
以下をfunctions.php に追記することでアイキャッチ画像を含めることができる。
0 1 2 3 4 5 6 7 8 9 10 11 12 13 |
//テーマフォルダのfunctions.php //RRSSにアイキャッチ画像を入れる function post_thumbnail_in_feeds($content) { global $post; $image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full'); if(has_post_thumbnail($post->ID)) { $content = '<image><url>' . $image_url[0] . '</url></image>' . $content; } return $content; } add_filter('the_excerpt_rss', 'post_thumbnail_in_feeds'); add_filter('the_content_feed', 'post_thumbnail_in_feeds'); |