Skip to content

Instantly share code, notes, and snippets.

@spencejs
Created March 22, 2013 03:42
Show Gist options
  • Save spencejs/5218793 to your computer and use it in GitHub Desktop.
Save spencejs/5218793 to your computer and use it in GitHub Desktop.
Add Post Thumbnail to Feed in Wordpress
//Add Post Thumbnail to Feed
function feedFilter($query) {
if ($query->is_feed) {
add_filter('the_content', 'feedContentFilter');
}
return $query;
}
add_filter('pre_get_posts','feedFilter');
function feedContentFilter($content) {
$thumbId = get_post_thumbnail_id();
if($thumbId) {
$img = wp_get_attachment_image_src($thumbId);
$image = '<img align="left" src="'. $img[0] .'" alt="" width="'. $img[1] .'" height="'. $img[2] .'" />';
echo $image;
}
return $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment