Advertisement
IdeaG

thumbnail in WordPress feed

Feb 18th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement