这是暗中操作,但您是否尝试过使用set_object_terms
为您的bam_save_event_cat
作用
function bam_save_event_cat( $post_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids ) {
$taxonomy = \'categoria\';
$tribe_cats = get_the_terms( $post_id, \'tribe_events_cat\');
foreach($tribe_cats as $tribe_cat) {
if( empty($tribe_cat->name) ) continue;
$catname = $tribe_cat->name;
$cats[] = $catname;
}
wp_set_object_terms( $post_id, $cats, $taxonomy );
}
function bam_save_event($post_id) {
if ( defined( \'DOING_AUTOSAVE\' ) && DOING_AUTOSAVE )
return;
if ( !current_user_can( \'edit_post\', $post_id ) )
return;
if(get_post_type( $post_id ) == \'tribe_events\' ) {
remove_action( \'save_post\', \'bam_save_event\' );
wp_update_post( array( \'ID\' => $post_id ) );
add_action( \'save_post\', \'bam_save_event\' );
add_action( \'set_object_terms\', \'bam_save_event_cat\', 10, 6 );
}
}
add_action( \'save_post\', \'bam_save_event\' );