Create invidual specific categories to custom post type

How to programaticly add categories(Taxonomy) to custom post type?
I would like add 4 or more category(Elite, Global, Bronze, Silver) to my custom post type. Here is my code:

public function set_custom_post_types()
    {
$labels = array(
            "name" => __( 'Sponsors', '' ),
            "singular_name" => __( 'Sponsor', '' ),
            "menu_name" => __( 'Sponsors', '' ),
            "all_items" => __( 'Sponsors', '' ),
            "add_new" => _x('Add new Sponsor', 'book', 'sii-plugin'),
        );

        $this->post_types['sponsors'] = array(
            "label" => __( 'Sponsors', '' ),
            "labels" => $labels,
            "description" => "",
            "public" => true,
            "publicly_queryable" => true,
            "show_ui" => true,
            "show_in_rest" => false,
            "rest_base" => "",
            "has_archive" => false,
            "show_in_menu" => "edit.php?post_type=events",
            "capability_type" => "post",
            "map_meta_cap" => true,
            "hierarchical" => false,
            "rewrite" => array( "slug" => "sponsors", "with_front" => true ),
            "query_var" => true,
            "menu_position" => 5,
            "supports" => array( "title", "thumbnail" ),
            'taxonomies'          => array( 'category' )
        );
        return $this->post_types;
    }

Read more here: Create invidual specific categories to custom post type

Leave a Reply

Your email address will not be published. Required fields are marked *