how to integrate expiration date for a post
Hello everyone,
i found a code for the expiration date of Posts, Ads, pages, etc.
http://coderrr.com/wordpress-post-expiration/
function is_post_expired($post_ID = null){
if(!$post_ID) global $post;
$post_ID = $post_ID ? $post_ID : $post->ID;
//Human Friendly Expiration Date
$expiration = get_post_meta($post_ID, 'expiration', true);
//Adjust server time for your timezone
date_default_timezone_set('American/New_York');
$expiration_timestamp = strtotime($expiration);
$time_left = $expiration_timestamp - time();
if($time_left < 0):
if(expire_post($post_ID))
return true;
endif;
}
function expire_post($post_ID){
$args = array(
'ID' => $post_ID,
'post_status' => 'draft'
);
if(wp_update_post($args))
return true;
}
Simply include the following in the loop.
if(!is_post_expired()):
//Do something awesome here
else:
continue;
endif;
But in which loop do i have to add this code. Loop-ad-listing of my child theme or Loop of classipress.
Thanks in advance