Skip to content

Instantly share code, notes, and snippets.

@jadealombro
Created August 20, 2024 15:08
Show Gist options
  • Save jadealombro/c9bfaf8f615672c469ccf70c77a2316d to your computer and use it in GitHub Desktop.
Save jadealombro/c9bfaf8f615672c469ccf70c77a2316d to your computer and use it in GitHub Desktop.
Add featured image url and formatted published date in RSS feed on WordPress
function add_new_rss_fields() {
global $post;
if(has_post_thumbnail($post->ID)) {
$thumbnail = get_attachment_link(get_post_thumbnail_id($post->ID));
echo"\t<image>{$thumbnail}</image>\n";
}
$published_date = get_the_date( 'm/d/Y', $post->ID );
echo"\t<publishedDate>{$published_date}</publishedDate>\n";
}
add_action('rss2_item', 'add_new_rss_fields');
add_action('rss_item', 'add_new_rss_fields');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment