我在显示自定义帖子时遇到问题-我希望每个帖子仅在自定义字段中设置的日期未过时显示。
我不知道应该将if语句放在代码中的什么位置。我的想法是:
if($daysleft >= 0)
then execute the while "custom post";
以下代码显示了所有自定义帖子-过期和未过期:<?php
while(have_posts() ) : the_post();
$date = get_post_meta($post->ID, \'_single_date\', true);
$daysleft = round( ($date-time()) / 24 / 60 / 60); ?>
<div class="coupon-date">
<?php
if($date == \'\')_e(\'valid\', \'Couponize\');
else if($daysleft <= 0) _e(\'expired\', \'Couponize\');
else echo sprintf( _n(\'%d day left.\', \'%d days left.\', $daysleft, \'Couponize\'), $daysleft );
?>