How to add featured images into RSS feed for widgets on a code level

hey I’d like to show the featured image for RSS widgets and saw an example on a code level online. Can someone confirm that this will work and where to place it in the X-Theme?

function featuredtoRSS($content) {
global $post;
if ( has_post_thumbnail( $post->ID ) ){
$content = ‘

’ . get_the_post_thumbnail( $post->ID, ‘medium’, array( ‘style’ => ‘margin-bottom: 15px;’ ) ) . ‘
’ . $content;
}
return $content;
}

add_filter(‘the_excerpt_rss’, ‘featuredtoRSS’);
add_filter(‘the_content_feed’, ‘featuredtoRSS’);

Hi there,

The code above actually is not theme specific and related to the WordPress itself. You can read more about the actions in use here:

https://codex.wordpress.org/Template_Tags/the_excerpt_rss

https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content_feed

The Code also should work with our theme. Thank you.

I get that. However, * where * do I put it? Where, relative to the X-Theme, do I put the code?

Hi There,

That is a custom function so it should go to the child theme’s functions.php file. Regretfully we can not provide support for 3rd party scripts, with that said you need to consult the documentation or the author of this function for integrating it to a theme.

Thank you for understanding,

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.