atmd
atmd

Reputation: 7490

wordpress display posts published with a publish date in the future

Need help with a wordpress problem.

I need to edit the query.php to ONLY get posts published today OR in the future. Im getting future post fine by changing:

$where .= " AND ($wpdb->posts.post_status = 'publish'";

to

$where .= " AND ($wpdb->posts.post_status = 'publish' OR";
        $where .= " $wpdb->posts.post_status = 'future'";

But Im still getting old posts

Any ideas?

thanks

EDIT: I have

iv got in $where .= " AND $wpdb->posts.post_date >= '" . date('Y-m-d') . "' ";

But it doesn seen to effect the results. I have echo'd the $where and the date is showing as 2011-11-22, Does anyone know if this is the correct format?

Upvotes: 0

Views: 903

Answers (1)

Kevin Vandenborne
Kevin Vandenborne

Reputation: 1387

I'm not very familiar with wordpress but publish would return everything with that status, thus including posts published in the past.

You should be able to do something like

$where .= " AND $wpdb->posts.post_status = 'publish'";
$where .= " AND $wpdb->posts.post_date >= NOW()";

Upvotes: 2

Related Questions