How to display Post Thumbnails in WordPress feeds [CODE]

GD Star Rating
loading...

When year ago I was working on new functions for e-art.lv, I decide to use Post Thumbnails In WordPress Feeds. There were several reasons why we (e-art.lv) started to use that “feature“. We saw that some of RSS aggregators are using these features from other RSS and Atom feeds.  We wanted them too… Here is my solution for post thumbnails in WordPress excerpt feeds.

post thumbnails in wordpress blog feed

Code of Post Thumbnails In WordPress Feeds

// Post thumbnails in RSS from Simple Media Code
// http://simplemediacode.info/?p=248 by http://Umbrovskis.com
function me3_rssthumbnails($content) {
global $post;
if (has_post_thumbnail($post->ID)){
$content = ''.get_the_post_thumbnail($post->ID,'medium',
array('align'=>'left','alt'=>$post->post_title))."n".$content;
}
return $content;
}
add_filter('the_excerpt_rss', 'me3_rssthumbnails');

Here comes code explanation:

we are taking existing content of RSS

me3_rssthumbnails($content)

we are taking uploaded image from post

has_post_thumbnail( $post->ID )) 

Here we are taking medium size image from post, aligning it to left, and taking post title as descriptional text in alt attribute.

$post->ID,'medium',array('align'=>'left','alt'=>$post->post_title)

Download as WordPress plugin

More info about used WordPress functions

  • http://codex.wordpress.org/Function_Reference/has_post_thumbnail
  • http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail
  • http://codex.wordpress.org/Function_Reference/add_filter
GD Star Rating
loading...

When year ago I was working on new functions for e-art.lv, I decide to use Post Thumbnails In WordPress Feeds. There were several reasons why we (e-art.lv) started to use that “feature”. We saw that some of RSS aggregators are usign these features from other RSS and Atom feeds. We wanted them too… Here is my solution…. How to display Post Thumbnails in WordPress feeds [CODE]

No comments yet.

Leave a Reply

Your email is never published nor shared.

*

You may use these HTML tags and attributes:
<a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>