Search
Close this search box.

WordPress RSS Feed With Featured Image

[updated_on]
Share this post:
function featuredtoRSS($content) {
global $post;
 if ( has_post_thumbnail( $post->ID ) ){
  $content = '<div>' . get_the_post_thumbnail( $post->ID, 'medium', array( 'style' => 'margin-bottom: 15px;' ) ) . '</div>' . $content;
 }
return $content;
}
 
add_filter('the_excerpt_rss', 'featuredtoRSS');
add_filter('the_content_feed', 'featuredtoRSS');
Share this post:

1 thought on “WordPress RSS Feed With Featured Image”

  1. Hi Bjorn,
    I used this function with a live site and give me an error. “!PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘create_posttype’ not found or invalid function name in /var/www/vhosts/*****/httpdocs/wp-includes/class-wp-hook.php on line 286!”
    I deleted “add_action( ‘init’, ‘create_posttype’ );” and works well and don’t give any error.
    It’s necessary to put this action? It’s possible it could be add_action( ‘init’, ‘create_post_type’ );” ?
    Thanks!

Leave a Comment

Your email address will not be published. Required fields are marked *

WPLearningLab