Save metabox checkboxes values to custom content type

I have rethought the problem:

Finally, I resolve it with save_post hook:

function enhanced_portfolio_categories_save_post(){

    $terminos = array();
    foreach ($_POST['my_categories'] as $key) {
        $custom_tax = get_term_by('term_id', $key, 'portfolio_categories');
        array_push($terminos, $custom_tax->term_id);
    }

    wp_set_object_terms( $_POST['post_ID'], $terminos, 'portfolio_categories');

}

Leave a Comment