Last active
January 20, 2019 16:36
-
-
Save adamlaki/7f0681678c3326ba13738ed6ed139b0d to your computer and use it in GitHub Desktop.
How to Add Featured Image to RSS Feeds in WordPress - Add as an individual item
This file contains hidden or 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
<?php | |
function pine_feed_add_image( ) { | |
global $post; | |
$output = ''; | |
if( get_post_type() !== 'post' ) { | |
return; | |
} | |
if( has_post_thumbnail( $post->ID ) ) { | |
$output = '<media:content xmlns:media="http://search.yahoo.com/mrss/" url="' . get_the_post_thumbnail_url($post->ID, 'your-image-size' ) . '" medium="image" type="image/jpg" />'; | |
} | |
echo $output; | |
} | |
add_filter( 'rss2_item', 'pine_feed_add_image' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment