admin管理员组文章数量:1278882
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' );
}
}
}
}
}
本文标签: custom post typessetobjectterms action hook based on the function in the published CPT
版权声明:本文标题:custom post types - set_object_terms action hook based on the function in the published CPT 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741232490a2362361.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论