Created
January 11, 2017 14:04
-
-
Save mattpramschufer/3d11123879fe2e962ed805c140d6b01e to your computer and use it in GitHub Desktop.
Add Featured Image to RSS Feed Description and Create separate image Node in Wordpress,
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
<?php | |
// Add the image and thumbnail node to RSS feed | |
function add_rss_node_image_thumbnail() { | |
global $post; | |
if (has_post_thumbnail($post->ID)): | |
echo "<image>" . get_the_post_thumbnail_url($post->ID, 'medium') . "</image>\n"; | |
endif; | |
} | |
add_action('rss2_item', 'add_rss_node_image_thumbnail'); | |
function add_rss_image_thumbnail($content) { | |
global $post; | |
if ( has_post_thumbnail( $post->ID ) ){ | |
$content = '<div>' . get_the_post_thumbnail( $post->ID, 'large' ) . '</div>' . $content; | |
} | |
return $content; | |
} | |
add_filter('the_excerpt_rss', 'add_rss_image_thumbnail'); | |
add_filter('the_content_feed', 'add_rss_image_thumbnail'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment