Skip to content

Instantly share code, notes, and snippets.

@JanThiel
Last active October 31, 2018 19:20
Show Gist options
  • Save JanThiel/b147cd1761384bf5995ae686e60e1256 to your computer and use it in GitHub Desktop.
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/
<?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