I have a problem with displaying custom posts – I want each post to show only if a date set in a custom field has not passed.
I can’t figure out the where I should put the if statement in the code. My idea is:
if($daysleft >= 0)
then execute the while "custom post";
The following code is displaying the all the custom posts – both expired and not expired:
<?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 );
?>