How to display future post in WordPress

This is small snippet to display all future posts starting today. Add this before doing the loop

<?php
function filter_where($where = '') {
  //posts in the last 30 days
  $where .= " AND post_date >= '". date('Y-m-d', strtotime('now')) . "'";
  return $where;
}
add_filter('posts_where', 'filter_where');
query_posts($query_string . "post_status=future,publish&orderby=date&order=ASC");
?>

You can limit the result or change order. See Codex for details of using query_posts


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Hosted by BOC Indonesia