wp_set_object_terms doesn’t work as expected

I am tring to set custom post term from different taxonomies when the post page loads, and i have an array has taxonomy slug as key and term id as value, and i have mapped values to make sure they are integers, and when i var_dump it i get

array(4) {
[“languages”]=>
int(280)
[“video_qualities”]=>
int(239)
[“video_extensions”]=>
int(234)
[“video_effects”]=>
int(174)
}

And taxonomy names are exactly the same also IDs exists, so i used this loop to add terms to the post

global $post
foreach($custom_taxs as $taxName => $termID){
if(!has_term($termID,$taxName,$post->ID)){

$check = wp_set_object_terms( $post->ID, $termID , $taxName);
}

}

And it adds all terms except the last one with id 174, and i don’t know why.
Then i tried to explicitly add it with

wp_set_object_terms( $post->ID, array(174) , ‘video_effects’);

But no change, So why this happens, and here is the link from the video_effects admin page to make sure i am using correct taxonomy name

http://cdn.prosentra.com/wp-admin/edit-tags.php?taxonomy=video_effects&post_type=project

Read more here:: wp_set_object_terms doesn’t work as expected

Leave a Reply

Your email address will not be published. Required fields are marked *