Skip to content

Instantly share code, notes, and snippets.

@shelleyhoward
Created January 24, 2014 20:46
Show Gist options
  • Save shelleyhoward/8606049 to your computer and use it in GitHub Desktop.
Save shelleyhoward/8606049 to your computer and use it in GitHub Desktop.
<?php
/**
* Add Taxonomies
* @author Shelley Howard
* @link http://shelleyhoward.com
* http://codex.wordpress.org/Function_Reference/register_taxonomy
*/
// hook into the init action and call create_taxonomies when it fires
add_action( 'init', 'sh_create_taxonomies', 0 );
// create new taxonomies for the post type "post"
function sh_create_taxonomies() {
// Add new taxonomy, make it hierarchical (like categories)
$labels = array(
'name' => _x( 'Stores', 'stores' ),
'singular_name' => _x( 'Store', 'stores' ),
'search_items' => _x( 'Search Stores', 'stores' ),
'popular_items' => _x( 'Popular Stores', 'stores' ),
'all_items' => _x( 'All Stores', 'stores' ),
'parent_item' => _x( 'Parent Store', 'stores' ),
'parent_item_colon' => _x( 'Parent Store:', 'stores' ),
'edit_item' => _x( 'Edit Store', 'stores' ),
'update_item' => _x( 'Update Store', 'stores' ),
'add_new_item' => _x( 'Add New Store', 'stores' ),
'new_item_name' => _x( 'New Store', 'stores' ),
'separate_items_with_commas' => _x( 'Separate stores with commas', 'stores' ),
'add_or_remove_items' => _x( 'Add or remove stores', 'stores' ),
'choose_from_most_used' => _x( 'Choose from the most used stores', 'stores' ),
'menu_name' => _x( 'Stores', 'stores' ),
);
$args = array(
'labels' => $labels,
'public' => true,
'show_in_nav_menus' => true,
'show_ui' => true,
'show_tagcloud' => true,
'show_admin_column' => true,
'hierarchical' => true,
'query_var' => true,
'rewrite' =>
array(
'slug' => 'store',
'with_front' => false, // Don't display the category base before "/Stores/"
'hierarchical' => true ),
);
register_taxonomy( 'store', array('post'), $args );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment