add_action('expire_posts', 'expire_posts_function');
function expire_posts_function() {

  $today = date('Y-m-d');

    $args = array(

        'post_type' => array('vacatures'),

        'posts_per_page' => -1

    );

    $posts = get_posts($args);

    $today = strtotime($today);

    foreach($posts as $p){

        $expiredate = get_field('uiterste_reactie_datum', $p->ID, false, false);

        $expiredate = strtotime($expiredate);

        if ($expiredate) {

            if($expiredate < $today){
        update_field( 'verlopen', '1', $p->ID );

            } else {

                update_field( 'verlopen', '0', $p->ID );

            }

        }

    }

    if (function_exists('FWP')) {

            FWP()->indexer->index();

  }

}

 

Geef een reactie 0