Posted By

chrisaiv on 09/13/14


Tagged

wordpress


Versions (?)

Wordpress: Show Featured Images In Feed


 / Published in: PHP
 

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

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.

  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');

Report this snippet  

You need to login to post a comment.