In wordpress add tags and categories to custom post type

Many times we use the custom post type in wordpress. Wordpres tutorial, In wordpress add tags and categories to custom post type.  Some times we need to category and tags for custom post type which associated.

In wordpress add tags and categories to custom post type

you can use the following code in functions.php file.

01// === CUSTOM POST TYPES === //
02function create_my_post_types() {
03    register_post_type( 'Services',
04        array(
05            'labels' => array(
06                'name' => __( 'Services' ),
07                'singular_name' => __( 'Services' ),
08                'add_new_item' => 'Add New Services',
09                'edit_item' => 'Edit Services',
10                'new_item' => 'New Services',
11                'search_items' => 'Search Services',
12                'not_found' => 'No Services found',
13                'not_found_in_trash' => 'No Services found in trash',
14            ),
15            '_builtin' => false,
16            'public' => true,
17            'hierarchical' => false,
18            'taxonomies' => array( 'website_type', 'service'),
19            'supports' => array(
20                'title',
21                'editor',
22                'excerpt',
23                                'thumbnail'
24            ),
25            'rewrite' => array( 'slug' => 'services', 'with_front' => false ),
26 
27        )
28    );
29}
30add_action( 'init', 'create_my_post_types' );
31 
32// === CUSTOM TAXONOMIES === //
33function my_custom_taxonomies() {
34    register_taxonomy(
35        'website_type',     // internal name = machine-readable taxonomy name
36        'Services',     // object type = post, page, link, or custom post-type
37        array(
38            'hierarchical' => true,
39            'label' => 'Website Types'// the human-readable taxonomy name
40            'query_var' => true, // enable taxonomy-specific querying
41            'rewrite' => array( 'slug' => 'website_type' ),   // pretty permalinks for your taxonomy?
42        )
43    );
44    register_taxonomy(
45        'service',
46        'post',
47        array(
48            'hierarchical' => false,
49            'label' => 'Service',
50            'query_var' => true,
51            'rewrite' => array( 'slug' => 'service' ),
52        )
53    );
54 
55}
56add_action('init', 'my_custom_taxonomies', 0);

Please consult with your developer.

In wordpress add tags and categories to custom post type
In wordpress add tags and categories to custom post type

 

……………………..