How to remove published date from RSS feed

Note that if you remove the <pubDate> tag from the rss2 feed, then it will become unvalid.

So you don’t want to do that!

If it’s empty:

<pubDate></pubDate> 

then the feed will still not validate:

> pubDate must be an RFC-822 date-time

So that wouldn’t be an option either.

If you want it static, for all items, then you could use e.g.:

add_filter( 'get_post_time', 'wpse_static_rss2_feed_time', 10, 3 ); 

function wpse_static_rss2_feed_time( $time, $d, $gmt )
{
    if( did_action( 'rss2_head' ) )
        $time="Thu, 01 Jan 1970 00:00:00 +0000";
    return $time;
}

where you can modify the static value to your needs.

Similar can be done for the atom feed.

Note the atom feed also has the <updated> tag that get’s it’s value from get_post_modified_time():

Here’s an example:

add_filter( 'get_post_time',          'wpse_static_atom_feed_time', 10, 3 ); 
add_filter( 'get_post_modified_time', 'wpse_static_atom_feed_time', 10, 3 ); 

function wpse_static_atom_feed_time( $time, $d, $gmt )
{
    if( did_action( 'atom_head' ) )
        $time="1970-01-01T00:00:00Z";
    return $time;
}

Also note the different time format.

Leave a Comment