sleepingegg.net – Tips

A daily failure and occasional success

WordPressのFeedに画像を表示する

Posted on | 2011.09.16 |

仕事で WordPress で管理するブログのフィードを MagpieRSS を使ってウェブページに表示する作業をしていましたが、画像も表示する必要があったので検索してみたところ、該当するプラグインは見つかりませんでしたが、wp-include にある feed_rss2.php, feed-rdf.php, feed-rss.php のファイルを書き換えることで対応できるとのことで、さっそくトライしてみました。


【検証バージョン】
Wordpress 3.0.2


・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 (get_option(‘rss_use_excerpt’)) : ?>
<description><![CDATA[<?php the_content_feed('rss2') ?>]]></description>
<?php else : ?>
<description><![CDATA[<?php the_content_feed('rss2') ?>]]></description>



・wp-includes/feed-rdf.phpを編集
赤字が訂正箇所です

<?php if (get_option(‘rss_use_excerpt’)) : ?>
<description><?php the_excerpt_rss() ?></description>
<?php else : ?>
<description><?php the_excerpt_rss() ?></description>
                 ↓
<?php if (get_option(‘rss_use_excerpt’)) : ?>
<description><?php the_content_feed(‘rdf’) ?></description>
<?php else : ?>
<description><?php the_content_feed(‘rdf’) ?></description>



・wp-includes/feed-rss.phpを編集
赤字が訂正箇所です

<title><?php the_title_rss() ?></title>
<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
                 ↓
<title><?php the_title_rss() ?></title>
<description><![CDATA[<?php the_content_feed('rdf') ?>]]></description>



今回は上記の書き換えで対応できましたが WordPress のバージョンによりソースが大きく変わることが多いため、アップグレード時には注意しておきたいところです。



【参考サイト様一覧】


コメントを書く |

Comments

Leave a Reply





あわせて読みたい