- This topic has 0 replies, 1 voice, and was last updated 3 weeks, 3 days ago by .
Viewing 0 reply threads
Viewing 0 reply threads
- You must be logged in to reply to this topic.
Welcome › mkmcst community Forum › Web programming › WordPress › Random wordpress › Show Post Thumbnails in RSS Feed
By default WordPress will only show text in your RSS feed but if you want to include your set featured image this snippet will do that.
This will add the post’s featured thumbnail before your content in your site’s RSS feed.
<?php
//This will prepend your WordPress RSS feed content with the featured image
add_filter('the_content', 'smartwp_featured_image_in_rss_feed');
function smartwp_featured_image_in_rss_feed( $content ) {
global $post;
if( is_feed() ) {
if ( has_post_thumbnail( $post->ID ) ){
$prepend = '<div>' . get_the_post_thumbnail( $post->ID, 'medium', array( 'style' => 'margin-bottom: 10px;' ) ) . '</div>';
$content = $prepend . $content;
}
}
return $content;
}