image thumbnail in RSS Feed

If you are using the native RSS feeds then the post thumbnail can be added by a filter hook:

function insertThumbnailRSS($content) {
    global $post;
    if ( has_post_thumbnail( $post->ID ) ){
        $content="" . get_the_post_thumbnail( $post->ID, 'thumbnail', array( 'alt' => get_the_title(), 'title' => get_the_title(), 'style' => 'float:right;' ) ) . '' . $content;
    }
    return $content;
}
add_filter('the_excerpt_rss', 'insertThumbnailRSS');
add_filter('the_content_feed', 'insertThumbnailRSS');

But if you are creating a custom feed then you can add the image using the_post_thumbnail eg:

<li>
    <p><?php echo $item->get_date('j F Y'); ?></p>
        <a target="_blank" href="https://wordpress.stackexchange.com/questions/100968/<?php echo esc_url( $item->get_permalink() ); ?>"title="<?php echo "Posted '.$item->get_date('j F Y | g:i a'); ?>'> 
        <strong> <?php echo esc_html( $item->get_title() ); ?> </strong></a>
        <?php // check if the post has a Post Thumbnail assigned to it.
        if ( has_post_thumbnail() ) { the_post_thumbnail(); } 
        ?>
}</li>

Leave a Comment

tech