Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

dumay-rua – CPT – taxonomy – location

if ( ! function_exists( 'dumayrua_projects_cpt_location' ) ) {

// Register Custom Taxonomy
function dumayrua_projects_cpt_location() {

	$labels = array(
		'name'                       => _x( 'Locations', 'Taxonomy General Name', 'dumayrua_projects_location' ),
		'singular_name'              => _x( 'Location', 'Taxonomy Singular Name', 'dumayrua_projects_location' ),
		'menu_name'                  => __( 'Locations', 'dumayrua_projects_location' ),
		'all_items'                  => __( 'All Locations', 'dumayrua_projects_location' ),
		'parent_item'                => __( 'Parent Location', 'dumayrua_projects_location' ),
		'parent_item_colon'          => __( 'Parent Location', 'dumayrua_projects_location' ),
		'new_item_name'              => __( 'New Location Name', 'dumayrua_projects_location' ),
		'add_new_item'               => __( 'Add New Location', 'dumayrua_projects_location' ),
		'edit_item'                  => __( 'Edit Location', 'dumayrua_projects_location' ),
		'update_item'                => __( 'Update Location', 'dumayrua_projects_location' ),
		'view_item'                  => __( 'View Location', 'dumayrua_projects_location' ),
		'separate_items_with_commas' => __( 'Separate locations with commas', 'dumayrua_projects_location' ),
		'add_or_remove_items'        => __( 'Add or remove locations', 'dumayrua_projects_location' ),
		'choose_from_most_used'      => __( 'Choose from the most used', 'dumayrua_projects_location' ),
		'popular_items'              => __( 'Popular locations', 'dumayrua_projects_location' ),
		'search_items'               => __( 'Search locations', 'dumayrua_projects_location' ),
		'not_found'                  => __( 'Not Found', 'dumayrua_projects_location' ),
		'no_terms'                   => __( 'No locations', 'dumayrua_projects_location' ),
		'items_list'                 => __( 'Locations list', 'dumayrua_projects_location' ),
		'items_list_navigation'      => __( 'Locations list navigation', 'dumayrua_projects_location' ),
	);
	$args = array(
		'labels'                     => $labels,
		'hierarchical'               => true,
		'public'                     => true,
		'show_ui'                    => true,
		'show_admin_column'          => true,
		'show_in_nav_menus'          => true,
		'show_tagcloud'              => true,
	);
	register_taxonomy( 'location', array( 'projects' ), $args );

}
add_action( 'init', 'dumayrua_projects_cpt_location', 0 );

}