Skip to content

Instantly share code, notes, and snippets.

@imvarunkmr
Last active April 29, 2017 11:06
Show Gist options
  • Save imvarunkmr/c2b9f7901b7c883ca77074f9cba4d62f to your computer and use it in GitHub Desktop.
Save imvarunkmr/c2b9f7901b7c883ca77074f9cba4d62f to your computer and use it in GitHub Desktop.
Registering a custom taxonomy
<?php
/**
* Add custom taxonomy for project services
*/
add_action( 'init', 'services', 0);
function services() {
$labels = array(
'name' => _x( 'Services', 'taxonomy general name', 'textdomain' ),
'singular_name' => _x( 'Service', 'taxonomy singular name', 'textdomain' ),
'search_items' => __( 'Search Services', 'textdomain' ),
'all_items' => __( 'All Services', 'textdomain' ),
'parent_item' => __( 'Parent Service', 'textdomain' ),
'parent_item_colon' => __( 'Parent Service:', 'textdomain' ),
'edit_item' => __( 'Edit Service', 'textdomain' ),
'update_item' => __( 'Update Service', 'textdomain' ),
'add_new_item' => __( 'Add New Service', 'textdomain' ),
'new_item_name' => __( 'New Service Name', 'textdomain' ),
'menu_name' => __( 'Service', 'textdomain' ),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'service' ),
);
register_taxonomy( 'service', array( 'book' ), $args );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment