Metabox for custom post type with termmeta saving


I’m trying to create a metabox for my custom post type: pro, which saves the information not in the postmeta table but in termmeta, I share the structure but does not save any data in the termmeta table, where am I wrong?


add_action( 'add_meta_boxes', 'AMC_servizio_uno' );
function AMC_servizio_uno() {
        'AMC_metabox_servizio_uno',         /*ID DELLA METABOX*/
        'Servizio uno',        /*TITOLO DELLA METABOX*/
        'plugin_add_custom_box',        /*CALLBACK DELLA METABOX*/
        'pro',                     /*TIPO DI POST CHE VOGLIAMO A CUI VENGA APPLICATA LA METABOX*/
        'side',                             /*POSIZIONE DELLA METABOX:*/
        'default' );                        /*PRIORITA' DELLA METABOX*/


// Print the meta box
add_action( 'servizi_pro_edit_form', 'plugin_add_custom_box' );
function plugin_add_custom_box( $term ) {
    $value = get_term_meta( $term->term_id, 'plugin_meta_key', true );
    <label for="plugin_meta_key">Description of the field: </label>
    <input name="plugin_meta_key" type="text" value="<?php echo $value; ?>">

// Save the meta value
add_action( 'edit_term', 'plugin_save_term_meta' );
function plugin_save_term_meta( $term_id ) {
    if ( array_key_exists( 'plugin_meta_key', $_POST ) ) {
            sanitize_text_field( $_POST['plugin_meta_key'] )

how can I do?

user14633289 2 months 0 Answers 17 views 0

Leave an answer