If enabled show time left, if disabled don't
The title kind of says it all but I was just wondering if there was a way to display the ‘time left’ (as I call it) within the post ONLY if the content scheduler is enabled.
At present it displays great for the posts with it enabled, but says ‘-15913 Days Left’ for all those who have the content scheduler disabled.
Here is my code, if you could tell me what to wrap it in I will be very grateful…
<?php global $wp_query; $postid = $wp_query->post->ID; //Convert to date $datestr=get_post_meta($postid, '_cs-expire-date', true);//Your date $date=strtotime($datestr);//Converted to a PHP date (a second count) //Calculate difference $diff=$date-time();//time returns current time in seconds $days=floor($diff/(60*60*24));//seconds/minute*minutes/hour*hours/day) //Report echo "$days Days Left"; ?>
- The topic ‘If enabled show time left, if disabled don't’ is closed to new replies.