Created
August 20, 2024 15:08
-
-
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
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
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