Skip to content

Instantly share code, notes, and snippets.

@pajtai
Last active September 18, 2015 02:50
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 pajtai/97c542f9432dcf37a6a1 to your computer and use it in GitHub Desktop.
Save pajtai/97c542f9432dcf37a6a1 to your computer and use it in GitHub Desktop.
Add custom element into Wordpress RSS feeds
add_action('atom_entry', 'add_thumbnail_to_feed');
add_action('rdf_item', 'add_thumbnail_to_feed');
add_action('rss_item', 'add_thumbnail_to_feed');
add_action('rss2_item', 'add_thumbnail_to_feed');
function add_thumbnail_to_feed(){
global $post;
if ( has_post_thumbnail( $post->ID ) ){
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail' );
$url = $thumb['0'];
echo "<thumbnail>$url</thumbnail>";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment