Posts wont expire

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?

Leave a Comment