Skip to content

Instantly share code, notes, and snippets.

@AlkarE
Created July 20, 2015 08:07
Show Gist options
  • Save AlkarE/d74ae491808fad9848d8 to your computer and use it in GitHub Desktop.
Save AlkarE/d74ae491808fad9848d8 to your computer and use it in GitHub Desktop.
product_category_taxonomy
<?php
/*Plugin Name: Create product Category Taxonomy
Description: This plugin registers the 'product category' taxonomy and applies it to the 'product' post type.
Version: 1.0
License: GPLv2
*/
function product_register_taxonomy() {
// set up labels
$labels = array(
'name' => 'Product Categories',
'singular_name' => 'Product Category',
'search_items' => 'Search Product Categories',
'all_items' => 'All Product Categories',
'edit_item' => 'Edit Product Category',
'update_item' => 'Update Product Category',
'add_new_item' => 'Add New Product Category',
'new_item_name' => 'New Product Category',
'menu_name' => 'Product Categories'
);
// register taxonomy
register_taxonomy( 'productcat', 'product', array(
'hierarchical' => true,
'labels' => $labels,
'query_var' => true,
'show_admin_column' => true
) );
}
add_action( 'init', 'product_register_taxonomy' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment