質問: 'tribe_events' ) { remove_action( 'save_post', 'bam_save_event' ); wp_update_post( array( 'id' => $post_id ) ); add_action( 'save_post', 'bam_save_event' ); bam_save_event_cat( $post_id ); } } add_action( 'save_post', 'bam_save_event' );
回答: これは暗闇の中での突き刺しですが、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' );