Skip to content

Instantly share code, notes, and snippets.

@anneallen
Last active August 26, 2015 17:52
Show Gist options
  • Save anneallen/66b3ea7f87abbd359bc6 to your computer and use it in GitHub Desktop.
Save anneallen/66b3ea7f87abbd359bc6 to your computer and use it in GitHub Desktop.
// hook into the init action and call create_boat_taxonomies when it fires
add_action( 'init', 'create_boat_taxonomies', 0 );
// create 2 taxonomies, Type, Manufacturer, for the post type "boat"
function create_boat_taxonomies() {
//*Type
$types = array(
// Pledge Items
array('the_type' => 'type',
'single' => 'Type',
'plural' => 'Types'));
foreach ($types as $type) {
$the_type = $type['the_type'];
$single = $type['single'];
$plural = $type['plural'];
$labels = array(
'name' => _x($plural, 'taxonomy general name' ),
'singular_name' => _x($single, 'taxonomy singular name' ),
'search_items' => __('Search '.$plural),
'all_items' => __( 'All'. $plural ),
'parent_item' => __( 'Parent'. $single ),
'parent_item_colon' => __( 'Parent'. $single.':' ),
'edit_item' => __( 'Edit '. $single ),
'update_item' => __( 'Update'. $single ),
'add_new_item' => __( 'Add New '. $single ),
'new_item_name' => __( 'New '. $single.' Name' ),
'menu_name' => __( $single ),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => $the_type ),
);
register_taxonomy( $the_type, array( 'boat','atv' ), $args );
}
//*Manufacturer
$types = array(
// Pledge Items
array('the_type' => 'manufacturer',
'single' => 'Manufacturer',
'plural' => 'Manufacturers'));
foreach ($types as $type) {
$the_type = $type['the_type'];
$single = $type['single'];
$plural = $type['plural'];
$labels = array(
'name' => _x($plural, 'taxonomy general name' ),
'singular_name' => _x($single, 'taxonomy singular name' ),
'search_items' => __('Search '.$plural),
'all_items' => __( 'All'. $plural ),
'parent_item' => __( 'Parent'. $single ),
'parent_item_colon' => __( 'Parent'. $single.':' ),
'edit_item' => __( 'Edit '. $single ),
'update_item' => __( 'Update'. $single ),
'add_new_item' => __( 'Add New '. $single ),
'new_item_name' => __( 'New '. $single.' Name' ),
'menu_name' => __( $single ),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => $the_type ),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment