Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Errors when adding Featured Image to RSS Feed

Discussion in 'Misc WordPress Requests' started by vickywood, Dec 11, 2017.

  1. vickywood


    Errors when adding Featured Image to RSS Feed, by vickywood

    I am trying to teach myself WordPress. I want to fix my RSS feed so that it includes the featured image and validates correctly.

    Currently my blog is set to show excerpts.

    I tried using a couple of different plugins but they didn’t work so I deleted them.

    Then, I added this code to the functions.php file (via a site-specific plugin):

    function featuredtoRSS($content) {
    global $post;
    if ( has_post_thumbnail( $post->ID ) ){
    $content = ” . get_the_post_thumbnail( $post->ID, ‘thumbnail’, array( ‘style’ => ‘float:left; margin:0 15px 15px 0;’ ) ) . ” . $content;
    return $content;

    add_filter(‘the_excerpt_rss’, ‘featuredtoRSS’);

    When I test the feed
    a) the images don’t display properly – depending on the feed reader they display erratically if at all and sometimes show as empty white boxes
    b) the feed does not validate on https://validator.w3.org.

    Errors when adding Featured Image to RSS Feed

Share This Page

Monarch Social Sharing Plugin