Skip to content

Instantly share code, notes, and snippets.

@cameronjonesweb
Last active July 22, 2018 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cameronjonesweb/d08d3ea66fa21543e752da54cd375f0f to your computer and use it in GitHub Desktop.
Save cameronjonesweb/d08d3ea66fa21543e752da54cd375f0f to your computer and use it in GitHub Desktop.
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