WordPress Last Updated Time Fix for Atom RSS Feed

I noticed for the longest time that updates to my blog posts wouldn’t propagate over to Bloglines. Digging a bit deeper I noticed that in my atom feed, the <updated> and the <published> timestamps were the same. Looking at the code generating those 2 lines revealed the problem:

<updated><?php the_time('c'); ?></updated>
<published><?php the_time('c'); ?></published>

It used the same code to generate the updated time and the published time. I scratched my head trying to figure out if there was a way to determine the last modified time for a particular post/entry. I didn’t want it to just returned the last modified time for the entire database, which is what the atom feed uses for the feed’s last modified time.

Searching online, I found this bug on WordPress: Atom feed entry updated field should use get_post_modified_time, not get_post_time. Apparently the correct thing to call is:
get_post_modified_time('Y-m-d\TH:i:s\Z', true);

Resulting in:

<updated><?php echo get_post_modified_time('Y-m-d\TH:i:s\Z', true); ?></updated>
<published><?php the_time('c'); ?></published>

Yep. That fixed my atom feed’s entry last updated time. Obviously I’m not using the latest WordPress version and although updating WordPress isn’t difficult, it’s not easy either. Updates should be fast and simple. One click that does back up, download newest version, install, and prompt me for any extra things I need to configure. If anything goes wrong, roll back to what it was previously.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.