Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Adds the post thumbnail to the WordPress RSS feed
<?php
add_action( 'rss2_item', 'cameronjonesweb_add_post_thumbnail_to_rss' );
function cameronjonesweb_add_post_thumbnail_to_rss() {
if ( has_post_thumbnail() ) {
printf(
"\t" . '<media:content url="%1$s" type="%2$s" />' . "\n",
esc_url( get_the_post_thumbnail_url() ),
esc_attr( get_post_mime_type( get_post_thumbnail_id() ) )
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.