Showing future posts in WordPress RSS feeds

Share

I have a web site which announces future events. In WordPress, you would adapt the publish date of the  post to suit the event’s start date. All is good on the web site itself. I use the c2c_get_upcoming_posts plugin to display them on the front page, but there are other ways.

The RSS feed is another matter. By default, WordPress only shows those posts which are current to date. Later posts are not visible, which defeats a bit the purpose of announcing an event. If the readers following the RSS feed are only informed on the day of the event, it is of little help.

I added the following function to the functions.php file (in the WordPress theme folder) to show future posts.

function include_calendar_posts($where) {
global $wpdb;
if ( is_feed() ){
// add SQL-syntax to default $where
$where .= " OR $wpdb->posts.post_status = 'future' " ;
}
return $where;
}
add_filter('posts_where','include_calendar_posts');
Pages:
  1. Since I run an aggregator, I warn you that, we through away posts that date to the future, to much chance of abuse and error, for dealing with blog posts. Yes, Events lists are useful to have, but a posting date for news, is a different entity to the start date and time for an Event. Ideally RSS should have an additional field for the date described by the news.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>