WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a function that expires posts on a date, and adds a check to the database. Now, I'd like the ability to "recycle" those posts with new expiration date, but in order to do this, I need to erase the _expiration_date_processed entry. Is the function below the best way to achieve this, especially in the case where there is a status change for multiple posts using quick edit? Thank you for any insights.

 function gcpl_draft_to_published($post){
  global $post;
  global $wpdb;
     $current_id = $post->ID;
     $processsql = 'select meta_value from '.$wpdb->postmeta.' where meta_key = "_expiration-date-processed" AND post_id = '.$current_id.'';
     $processresult = $wpdb->get_col($processsql);
      if (!empty($processresult)) foreach ($current_id as $a) {
       delete_post_meta($a->post_id, '_expiration-date-processed');
share|improve this question
up vote 0 down vote accepted

Nevermind, I was complicating this whole process because I wasn't thinking about just using get_post_meta().

 function gcpl_draft_to_published($post){
      $exp_processed = get_post_meta($post->ID, '_expiration-date-processed', true);
    // check if the custom field has a value
        if($exp_processed != '') {
          delete_post_meta($post->ID, '_expiration-date-processed');
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.