Tags

,

How to add Custom Taxonomy in WordPress

This code is add in your function.php file and after check in WordPress admin in leftside …


// product_category = This is your custom taxonomy type name
// product          = This is your custom post type name

function add_product_taxonomies() {

	register_taxonomy('product_category', 'product', array(
		'hierarchical' => true,
		'labels' => array(
			'name' => _x( 'Product Category', 'taxonomy general name' ),
			'singular_name' => _x( 'Category', 'taxonomy singular name' ),
			'search_items' =>  __( 'Search Categories' ),
			'all_items' => __( 'All Categories' ),
			'parent_item' => __( 'Parent Categories' ),
			'parent_item_colon' => __( 'Parent Categories:' ),
			'edit_item' => __( 'Edit Categories' ),
			'update_item' => __( 'Update Categories' ),
			'add_new_item' => __( 'Add New Categories' ),
			'new_item_name' => __( 'New Categories Name' ),
			'menu_name' => __( 'Categories' ),
		),

		'rewrite' => array(
			'slug' => 'product_category', 
			'with_front' => false,
			'hierarchical' => true
		),
	));
}
add_action( 'init', 'add_product_taxonomies', 0 ); 

Only example images is here :
new-taxonomy

Advertisements