wordpress change post status based on custom field

Im looking for some help on the following. Im using acf to set an end date of a post. This date is save like 2015-07-20T00:00:00. No i am looking for a way to automatically change a post status to ‘concept/draft’ when todays date is larger then this custom field value.

Is there a function to do this automatically? Tried a search but that only gave me a plugin and cant use that.

Read More

Hope someone can help me with this or put me in the right direction

Related posts

1 comment

  1. You need to know the action hook to find work on the time of changes. Example when custom field is updated, we have to change the post status. the following one helps you to do this.
    This will schedule the event daily to check the changes

    wp_schedule_event(time(), 'daily', 'my_hourly_event');
    

    And write a function to hook it.

    function my_hourly_event() {
    
                $update_post = array(
                'ID'            => $id,
                'post_status'   =>  'private',
                'post_type' =>  'job' );
                wp_update_post($update_post); }
    

    read more here to work on it.

    Kvcodes

Comments are closed.