Displaying custom posts only if custom meta box date is not expired
-
Hi,
I have a problem of Displaying custom posts – only if custom meta box date is not expired. 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(); $thumb = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); $discount = get_post_meta($post->ID, '_single_discount', true); $date = get_post_meta($post->ID, '_single_date', true); $code = get_post_meta($post->ID, '_single_code', true); $url = get_post_meta($post->ID, '_single_url', true); $daysleft = round( ($date-time()) / 24 / 60 / 60); ?> <div class="coupon-date"> <?php if($date == '')_e('Х?чинтэй', 'Couponize'); else if($daysleft <= 0) _e('Дууссан', 'Couponize'); else echo sprintf( _n('%d day left.', '%d Хоног ?лдсэн.', $daysleft, 'Couponize'), $daysleft ); ?> </div> <?php endwhile; ?>
Thanx in advance,
Anandmongol
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Displaying custom posts only if custom meta box date is not expired’ is closed to new replies.