Posts wont expire

I am having some trouble with scheduling posts to automatically expire (either by deleting or going to draft), every plugin I have tried does nothing and when it reaches the scheduled time nothing happens, which is making me think its probably some simple thing I keep overlooking..

I thought I might be a problem with wp-cron, but I don’t seem to have any trouble setting up a publish date in the future through wordPress.

Read More

I have the latest version of WordPress running, with multi-sites set-up. All plugins were at the latest version available at the moment.

Does anyone have any ideas?? I am running out of things to try…

Thanks in Advance

Tafts

Related posts

Leave a Reply

3 comments

  1. create for these posts a customfield with the name expires and the value is the date for disabling the post.
    Use the following code in the Loop of your theme.

    //Loop-Start
    if (have_posts()) : while (have_posts()) : the_post();
      $exTime = get_post_custom_values('expires');
      if (is_array($exTime)) {      
      $exString= implode($exTime);
      $seconds = strtotime($exString) - time();
    } else {
      $secondes = 1;
    }
    if ($seconds > 0) {
      echo "<h2>";
      the_title();
      echo "</h2>";
      the_content();
    }
    endwhile;
    endif;
    

    This code wont delete or drafting the posts. But you don’t see it in the front. Perhaos this is a possible solution for your problem?

  2. I got it working using the Post Expirator plugin, which also had the same problem, but by adding the following code to each loop right after ‘the_post();’ it checks the posts status on each page load, it is a temporary solution which seems to work for the moment.

    // check to see whether post has expired
    $expiration = get_post_meta($post->ID, "expiration-date", true);
    if ($expiration && (time() > $expiration)) {
        $postSettings = array(
            'post_status' => 'draft'
        );
    
        wp_update_post($postSettings);
    } else {
    // normal content goes here
    }