
thumbnail in WordPress feed
By:
IdeaG on
Feb 18th, 2013 | syntax:
PHP | size: 0.69 KB | hits: 12 | expires: Never
// put this into functions.php
add_filter('the_excerpt_rss','rss_filter') ;
add_filter('the_content_feed','rss_filter_full') ;
function rss_filter($content){
global $post;
$thumbId = get_post_thumbnail_id();
if($thumbId) {
$img = wp_get_attachment_image_src($thumbId, 'large');
return '<img src="'.$img[0].'" alt="'.$post->post_excerpt.' title="'.$post->post_excerpt.'""/>'.$content;
}
}
function rss_filter_full($content){
global $post;
$thumbId = get_post_thumbnail_id();
if($thumbId) {
$img = wp_get_attachment_image_src($thumbId, 'large');
return '<img src="'.$img[0].'" alt="'.$post->post_excerpt.'" title="'.$post->post_excerpt.'"/>'.$content;
}
}