Quantcast
Channel: Add featured image to RSS feed through child theme functions.php file - WordPress Development Stack Exchange
Viewing all articles
Browse latest Browse all 2

Add featured image to RSS feed through child theme functions.php file

$
0
0

I'm trying to add featured images to my RSS feed, on a blog running a pinbin child theme.

When I install and activate the plugin "Add featured image to RSS feed" it works.

When I try to paste the code of this plugin in my child functions.php file it doesn't work (in fact, no code I've found on the internet works when it's pasted in my functions.php file, like this one for example Can't Display Featured Image in RSS Feed )

The code is

function add_featured_image_to_feed($content) {
    global $post;
    if ( has_post_thumbnail( $post->ID ) ){
        $content = '' . get_the_post_thumbnail( $post->ID, 'large' ) . '' . $content;
    }
    return $content;
}

add_filter('the_excerpt_rss', 'add_featured_image_to_feed', 1000, 1);
add_filter('the_content_feed', 'add_featured_image_to_feed', 1000, 1);

What could I be doing wrong? Of course my blog is using the child theme and I've checked that other functions in the child functions.php file are working.


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images