3

I've removed dates from my theme because all of my content is evergreen. The dates aren't visible to visitors or search engine crawlers on the site.

But people can still see dates in my RSS feed with the <pubDate></pubDate> line. Is there a way I can remove this from my feed? Ideally through a hook or filter that I can add into my functions.php file to keep this change theme-specific.

1
  • google knows very well when you first published the post, and it is might also sent in the http headers. This is just a waste of your time IMO. Jul 7, 2016 at 18:07

1 Answer 1

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.