This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

thumbnail in WordPress feed

By: IdeaG on Feb 18th, 2013  |  syntax: PHP  |  size: 0.69 KB  |  views: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // put this into functions.php
  2.  
  3. add_filter('the_excerpt_rss','rss_filter') ;
  4. add_filter('the_content_feed','rss_filter_full') ;
  5. function rss_filter($content){
  6.   global $post;
  7.         $thumbId = get_post_thumbnail_id();
  8.         if($thumbId) {
  9.     $img = wp_get_attachment_image_src($thumbId, 'large');
  10.     return '<img src="'.$img[0].'" alt="'.$post->post_excerpt.' title="'.$post->post_excerpt.'""/>'.$content;
  11.   }
  12. }
  13.  
  14. function rss_filter_full($content){
  15.   global $post;
  16.         $thumbId = get_post_thumbnail_id();
  17.         if($thumbId) {
  18.     $img = wp_get_attachment_image_src($thumbId, 'large');
  19.     return '<img src="'.$img[0].'" alt="'.$post->post_excerpt.'" title="'.$post->post_excerpt.'"/>'.$content;
  20.   }
  21. }
clone this paste RAW Paste Data