WordPress RSSにサムネイル追加 令和版

function rss_post_thumbnail($content)
{
        global $post;

        $imgurl = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'thumbnail');

        if(has_post_thumbnail($post->ID))
        {
                $content = '<imgurl>' . $imgurl[0] . '</imgurl><text>' . $content . '</text>';

        }
        return $content;
}

add_filter('the_excerpt_rss', 'rss_post_thumbnail');
add_filter('the_content_feed', 'rss_post_thumbnail');
add_filter('wp_calculate_image_srcset_meta', '__return_null');

おすすめ