Results 1 to 1 of 1

Thread: how to integrate expiration date for a post

  1. #1
    Thread Starter
    covoiturage's Avatar
    Join Date
    Jan 2013
    Location
    Germany
    Posts
    255
    Thanks
    0
    Thanked 1 Time in 1 Post

    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. v1.2 expiration date visibility
    By bephuong in forum Report Clipper Bugs
    Replies: 11
    Last Post: November 22nd, 2011, 08:36 AM
  2. Ad Expiration Date
    By essej88 in forum ClassiPress General Discussion
    Replies: 2
    Last Post: June 7th, 2010, 08:27 PM
  3. Ad Expiration Date
    By essej88 in forum Help Using ClassiPress
    Replies: 1
    Last Post: December 31st, 1969, 07:00 PM