设置过期日期可能比设置期限更容易,然后可以对过期日期大于今天的帖子进行元查询:
$args = array(
\'posts_per_page\' => -1,
\'meta_key\' => \'expiration_date\',
\'meta_value\' => date(\'Y-m-d\'),
\'meta_compare\' => \'>=\',
\'orderby\' => \'meta_value\',
\'order\' => \'ASC\'
);
$posts = new WP_Query($args);