Created
February 12, 2015 12:07
-
-
Save rachelmccollin/0c08ae59fedd9390762c to your computer and use it in GitHub Desktop.
WPMU DEV snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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 | |
| */ | |
| // register two taxonomies to go with the post type | |
| function wpmudev_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', 'wpmudev_register_taxonomy' ); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment