I want to change the term in the custom taxonomy from the set of time intervals.
CPT = job, taxonomy = current-status, term = ongoing
The below code is not working and I don’t know the missing code. Please help me!
<?php
add_action( 'set_object_terms', 'job_expiration' );
function job_expiration() {
//Check the custom post type 'job'
if ( is_singular( 'job' ) ) {
//get the terms - category
$categories = get_the_terms( get_the_ID(), 'current-status' );
//check the term 'ongoing'
$term = term_exists( 'ongoing', 'current-status' );
if ( $term !== 0 && $term !== null ) {
//job expiration from the timestamp stored in db with key
$expire_timestamp = 'int';
$expire_timestamp = rwmb_meta( 'j_post_expire' );
$current_time = time();
// Ensure the timestamp parsed correctly.
if ( $expire_timestamp ) {
$seconds_between = ( (int)$expire_timestamp - (int)$current_time );
if ( $seconds_between >= 0 ) {
//change the post terms from 'ongoing' to 'expired'
wp_set_post_terms( $post->ID, array ( 368 ), 'current-status', true );
wp_remove_object_terms( $post->ID, array ( 367 ), 'current-status' );
}
}
}
}
}