Custom Meta Box (SELECT2) Not Saving Taxonomy Terms

I have the code, enter image description here

/*  * Add a metabox  * I hope you're familiar with add_meta_box() function, so, nothing new for you here  */ add_action( 'admin_menu', 'rudr_metabox_for_select2_cat' ); function rudr_metabox_for_select2_cat() {     add_meta_box( 'rudr_select2', 'Tune Category', 'rudr_display_select2_cat_metabox', 'post', 'side', 'high' ); } /*  * Display the fields inside it  */ function rudr_display_select2_cat_metabox( $  post_object ) {     // I decided to write all the metabox html into a variable and then echo it at the end     $  html = '';      // always array because we have added [] to our <select> name attribute     $  appended_cat = get_post_meta( $  post_object->ID, 'rudr_select2_cat',true );      /*      * It will be just a multiple select for tags without AJAX search      * If no tags found - do not display anything      * hide_empty=0 means to show tags not attached to any posts      */     if( $  cats = get_terms( 'category', 'hide_empty=0' ) ) {         $  html .= '<p><select id="rudr_select2_cat" name="rudr_select2_cat[]" single="single" style="width:99%;max-width:25em;">';         foreach( $  cats as $  cat ) {             $  selected = ( is_array( $  appended_cat ) && in_array( $  cat->term_id, $  appended_cat ) ) ? ' selected="selected"' : '';             $  html .= '<option value="' . $  cat->term_id . '"' . $  selected . '>' . $  cat->name . '</option>';         }         $  html .= '<select></p>';     }     echo $  html; } add_action( 'wp_ajax_mishagetcat', 'rudr_get_cat_ajax_callback' ); // wp_ajax_{action} function rudr_get_cat_ajax_callback(){      // we will pass post IDs and titles to this array     $  return = array();      $  cat = get_terms( array('taxonomy' => 'category','search'=> $  _GET['q'],'ignore_sticky_posts' => 1,));         foreach ( $  cat as $  cat ) {               // shorten the title a little             $  title = ( mb_strlen( $  cat->name ) > 50 ) ? mb_substr( $  cat->name, 0, 49 ) . '...' : $  cat->name;             $  return[] = array( $  cat->term_id, $  title ); // array( Post ID, Post Title )         }     echo json_encode( $  return );     die; } //auto_save add_action( 'save_post', 'rudr_save_metaboxdata', 10, 2 ); function rudr_save_metaboxdata( $  post_id, $  post ) {      if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $  post_id;      // if post type is different from our selected one, do nothing     if ( $  post->post_type == 'post' ) {         if( isset( $  _POST['rudr_select2_cat'] ) )             update_post_meta( $  post_id, 'rudr_select2_cat', $  _POST['rudr_select2_cat'] );         else             delete_post_meta( $  post_id, 'rudr_select2_cat' );         if( isset( $  _POST['rudr_select2_tags'] ) )             update_post_meta( $  post_id, 'rudr_select2_tags', $  _POST['rudr_select2_tags'] );         else             delete_post_meta( $  post_id, 'rudr_select2_tags' );     }     return $  post_id; } //add_script_&_stylesheet add_action( 'admin_enqueue_scripts', 'rudr_select2_enqueue' ); function rudr_select2_enqueue(){      wp_enqueue_style('select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css' );     wp_enqueue_script('select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js', array('jquery') );      // please create also an empty JS file in your theme directory and include it too     wp_enqueue_script('mycustom', get_template_directory_uri() . '/css/mycustom.js', array( 'jquery', 'select2' ) );   } 

enter image description here But Showing only deafult category.