I am using a WordPress RSS to use in my iOS project. The feed doesn’t have thumbnail links in it, so I searched and found this code to add thumbnail links to feed.
/* include thumbnail in RSS feed */
function add_thumb_to_RSS($content) {
global $post;
if ( has_post_thumbnail( $post->ID ) ){
$content = '' . get_the_post_thumbnail( $post->ID, 'thumbnail' ) . '' . $content;
}
return $content;
}
add_filter('the_excerpt_rss', 'add_thumb_to_RSS');
add_filter('the_content_feed', 'add_thumb_to_RSS')
This code adds the image link in feed, but it adds as html code in the beginning of description tag like this:
<description>
<![CDATA[
<img width="150" height="150" src="http://www.ipadia.co/wp-content/uploads/2012/02/sayfada-bul-150x150.png" class="attachment-thumbnail wp-post-image" alt="sayfada bul" title="sayfada bul" />Some text some text Some text some text Some text some text Some text some text Some text some text Some text some text ....
]]>
</description>
I want to add image link with another tag like <image> or <thumb> the link </thumb>. So I can parse this more easily.
How can I do this? Thanks in advance.
I solved it finally 🙂 I changed the function that I posted before. The new function is this:
This gives the image link in new tag
<post-thumbnail>like I wanted.