Showing future posts in WordPress RSS feeds

11 July 2010  |  Published in Software

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-sytax to default $where
$where .= " OR $wpdb->posts.post_status = 'future' " ;
}
return $where;
}
add_filter('posts_where','include_calendar_posts');

Share on Facebook   Share on Twitter

Leave a Response

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

You're just using IPv4. Your address is 38.107.191.113.

Disclaimer

This site does not reflect the views of my employer, nor that of the Internet Society or its Luxembourg chapter

SPF and DKIM adoption rate

  • E-mails reaching this server on 3 Sep 2010
    SPF enabled e-mails: 2.47%
    DKIM signed e-mails: 2.24%
    DKIM signed mails sent: 57

My Twitter feed

Archives



Valid XHTML 1.0 Transitional