简体   繁体   中英

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?

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()";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM