Create taxonomy from Custom Post Type

Very Simple Code Snippet for Creating Taxonomy for Custom Post Type

Register Custom Post Type

function Knowledge_base_init() {
$labels = array(
    'name'               => _x( 'Knowledge bases', 'post type general name', 'your-plugin-textdomain' ),
    'singular_name'      => _x( 'Knowledge base', 'post type singular name', 'your-plugin-textdomain' ),
    'menu_name'          => _x( 'Knowledge bases', 'admin menu', 'your-plugin-textdomain' ),
    'name_admin_bar'     => _x( 'Knowledge base', 'add new on admin bar', 'your-plugin-textdomain' ),
    'add_new'            => _x( 'Add New', 'Knowledge base', 'your-plugin-textdomain' ),
    'add_new_item'       => __( 'Add New Knowledge base', 'your-plugin-textdomain' ),
    'new_item'           => __( 'New Knowledge base', 'your-plugin-textdomain' ),
    'edit_item'          => __( 'Edit Knowledge base', 'your-plugin-textdomain' ),
    'view_item'          => __( 'View Knowledge base', 'your-plugin-textdomain' ),
    'all_items'          => __( 'All Knowledge bases', 'your-plugin-textdomain' ),
    'search_items'       => __( 'Search Knowledge bases', 'your-plugin-textdomain' ),
    'parent_item_colon'  => __( 'Parent Knowledge bases:', 'your-plugin-textdomain' ),
    'not_found'          => __( 'No Knowledge bases found.', 'your-plugin-textdomain' ),
    'not_found_in_trash' => __( 'No Knowledge bases found in Trash.', 'your-plugin-textdomain' )
);

$args = array(
    'labels'             => $labels,
    'public'             => true,
    'publicly_queryable' => true,
    'show_ui'            => true,
    'show_in_menu'       => true,
    'query_var'          => true,
    'rewrite'            => array( 'slug' => 'Knowledge_base' ),
    'capability_type'    => 'post',
    'has_archive'        => true,
    'hierarchical'       => false,
    'menu_position'      => null,
    'menu_icon' => admin_url() . 'images/media-button-video.gif',
    'supports'           => array( 'title', 'editor', 'author')
);

register_post_type( 'knowledge-base', $args );
}


add_action( 'init', 'create_knowledge_base_taxonomies', 0 );
function create_knowledge_base_taxonomies() {
// Add Tips taxonomies
$labels = array(
    'name'              => _x( 'Tips & Tricks', 'taxonomy general name' ),
    'singular_name'     => _x( 'Tips & Tricks', 'taxonomy singular name' ),
    'search_items'      => __( 'Search Tips & Tricks' ),
    'all_items'         => __( 'All Tips & Tricks' ),
    'parent_item'       => __( 'Parent Tips & Tricks' ),
    'parent_item_colon' => __( 'Parent Tips & Tricks:' ),
    'edit_item'         => __( 'Edit Tips & Tricks' ),
    'update_item'       => __( 'Update Tips & Tricks' ),
    'add_new_item'      => __( 'Add New Tips & Tricks' ),
    'new_item_name'     => __( 'New Tips & Tricks Name' ),
    'menu_name'         => __( 'Tips & Tricks' ),
);

$args = array(
    'hierarchical'      => true,
    'labels'            => $labels,
    'show_ui'           => true,
    'show_admin_column' => true,
    'query_var'         => true,
    'rewrite'           => array( 'slug' => 'tips' ),
);

register_taxonomy( 'tips', array( 'knowledge-base' ), $args );
}

That help you for creating taxonomy.