Removing lastBuildDate
:
lastBuildDate
should not be removed from the rss feed, it may cause rss feed validation error/warning.
However, it’s possible to filter the date using get_lastpostmodified
filter hook.
Filtering feed content listing:
The rules for filtering feed
content listing is the same as the rules for filtering any content listing in WordPress, the only difference is that you’ll have to use the WP_Query::is_feed check.
So in most cases, you’ll have to use WP_Query
accompanied by pre_get_posts
action hook and then use the CODE in a custom plugin or in the theme’s functions.php
file.
Also, to filter the date, you may use the date_query
.
Example CODE:
The CODE below lists only the posts from 3 days before now in the feed and gives an option to modify the value of lastBuildDate
(as you’ve asked in the question).
function wpse334869_lastBuildDate( $lastpostmodified ) {
// if you need, modify the $lastpostmodified here, before returning it
return $lastpostmodified;
}
function wpse334869_filter_feed( $query ) {
if( $query->is_feed() ) {
add_filter( 'get_lastpostmodified', 'wpse334869_lastBuildDate');
$query->set( 'date_query', array(
array(
'after' => '3 days ago'
)
) );
}
}
add_action( 'pre_get_posts', 'wpse334869_filter_feed' );
Note: This is just a sample concept CODE, so make sure you test it before using it on a live site.
Further Reading: