I want to tell you about “Adding thumbnails to RSS feed” or better to say “Show featured images in RSS feed“. This method will work with your WordPress RSS feed and with Feedburner RSS feed. As you know, you can add a featured image to your blog post and this image will be displayed in a specific place, somewhere near to your blog post excerpt on the home page of your blog (the place and size depends on your template).
Why to Show Featured Images in RSS Feed
To Make Your RSS Feed Look Better
Get More Traffic from Your RSS Feed
How to Show Featured Images in RSS Feed
1
2
3
4
5
6
7
8
9
10
| function featuredtoRSS( $content ) { global $post ; if ( has_post_thumbnail( $post ->ID ) ){ $content = '' . get_the_post_thumbnail( $post ->ID, 'thumbnail' , array ( 'style' => 'float:left; margin:0 15px 15px 0;' ) ) . '' . $content ; } return $content ; } add_filter( 'the_excerpt_rss' , 'featuredtoRSS' ); add_filter( 'the_content_feed' , 'featuredtoRSS' ); |
Styling Your Featured Images in RSS Feed
Size of the Featured Images
. get_the_post_thumbnail( $post->ID, 'thumbnail'
change the word ‘thumbnail‘ to ‘medium‘, ‘large‘ or ‘full‘ (‘full’ will show the original size of your thumbnail image, I’m using full images). It will be a good idea to delete floating if you will change the size to ‘large‘ or ‘full‘, because images will not fit to your text. So read my next tip.Style of the Featured Images
'float:left; margin:0 15px 15px 0;'
. Change that line to this one (with quotes): 'float:right; margin:0 20px 20px 20px;'
.
1
2
3
4
5
6
7
8
9
10
| function featuredtoRSS( $content ) { global $post ; if ( has_post_thumbnail( $post ->ID ) ){ $content = '<div>' . get_the_post_thumbnail( $post ->ID, 'thumbnail' , array ( 'style' => 'margin-bottom: 15px;' ) ) . '</div>' . $content ; } return $content ; } add_filter( 'the_excerpt_rss' , 'featuredtoRSS' ); add_filter( 'the_content_feed' , 'featuredtoRSS' ); |
No comments:
Post a Comment