After experiencing social media and how web sharing works, I understood that images are very important for the promotion of blog posts. Having been using WordPress for quite some time, I’ve seen that Featured Images are a great way to make an image appear differently on the main page and inside the post page and by using thumbnails you can have both worlds; beautiful and small thumbnails on the main page and a full image inside the post.
One problem that this has created though, is that WordPress by default does not show the Featured Post image inside your blog’s RSS feed. By adding the hook code below in functions.php of your theme, the post thumbnail will appear on the feed:
function custom_content_feed($content) { return wp_get_attachment_image(get_post_thumbnail_id(), 'full') . '<br />' . $content; } add_filter('the_content_feed', 'custom_content_feed');
If you would like the post thumbnail to be shown below the content, just change the second line to:
return $content . '<br />' . wp_get_attachment_image(get_post_thumbnail_id(), 'full');
Moreover, if an alternative image size is required, you can define it in the second parameter, e.g. replacing ‘full’ with ‘thumb’.
Of course, the wp_get_attachment_image documentation is available.
It’s actually easy to modify WordPress with just a few lines of code. More “WordPress Hacks” coming soon!
Thank you – this worked perfectly!
Glad I could help.
Thank you so much! Worked great :) Now images will be displayed on my facebook page! :)
Glad you liked it! :)
thanks Nik !
is there a way to set an default image, if there is no featured image?
Hi, ethan!
If there is no featured image the wp_get_attachment_image function will return an empty string and so you may replace the code as:
I haven’t tested it but it should work…