Last active
September 18, 2015 02:50
-
-
Save pajtai/97c542f9432dcf37a6a1 to your computer and use it in GitHub Desktop.
Add custom element into Wordpress RSS feeds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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