Wordpress: Show Featured Images In Feed


/ Published in: PHP
Save to your folder(s)

To encourage subscribers to visit your website, rather than letting them just consume content through your RSS feed, you might want to display only the excerpt and featured image of posts.


Copy this code and paste it in your HTML
  1. /** ******** ******** ******** ******** ******** ******** ******** ********
  2. * Title: Show Featured Images In Feed
  3. * Description: Same as above
  4. * http://www.smashingmagazine.com/2011/12/07/10-tips-optimize-wordpress-theme/
  5. *
  6. *
  7. */
  8.  
  9. function rss_post_thumbnail($content) {
  10. global $post;
  11. if( has_post_thumbnail($post->ID) )
  12. $content = '<p>' . get_the_post_thumbnail($post->ID, 'thumbnail') . '</p>' . $content;
  13. return $content;
  14. }
  15. add_filter('the_content_feed', 'rss_post_thumbnail');

URL: http://www.smashingmagazine.com/2011/12/07/10-tips-optimize-wordpress-theme/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.