Last active
October 31, 2018 19:20
-
-
Save JanThiel/b147cd1761384bf5995ae686e60e1256 to your computer and use it in GitHub Desktop.
Minimum WordPress Plugin that adds <image> Tags to the RSS2 Feed. Add this file to a folder calles /wp-content/plugins/rss2-feed-with-images/
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 | |
/* | |
Plugin Name: RSS2 Feed with Images | |
Plugin URI: | |
Description: Add image objects to the RSS2 Feed | |
Version: 1.1 | |
Author: Jan Thiel | |
Author URI: https://hive-it.de | |
License: GPL2 | |
*/ | |
add_action( 'rss2_item', 'add_images_to_rss2_feed' ); | |
function add_images_to_rss2_feed() { | |
global $post; | |
if ( has_post_thumbnail( $post->ID ) ) { | |
$thumbnail = get_the_post_thumbnail_url( $post->ID, 'full' ); | |
echo("<image>{$thumbnail}</image>"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment