Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Testimonial Categories

Code for custom categories for a custom post type.

if ( ! function_exists( 'sam_register_testimonial_taxonomy' ) ) {

// Register Custom Taxonomy
function sam_register_testimonial_taxonomy() {

	$labels = array(
		'name'                       => _x( 'Categories', 'Taxonomy General Name', 'testimonials_widget' ),
		'singular_name'              => _x( 'Testimonial Category', 'Taxonomy Singular Name', 'testimonials_widget' ),
		'menu_name'                  => __( 'Testimonial Categories', 'testimonials_widget' ),
		'all_items'                  => __( 'All Categories', 'testimonials_widget' ),
		'parent_item'                => __( 'Parent Categories', 'testimonials_widget' ),
		'parent_item_colon'          => __( 'Parent Categories:', 'testimonials_widget' ),
		'new_item_name'              => __( 'New Category Name', 'testimonials_widget' ),
		'add_new_item'               => __( 'Add New Categories', 'testimonials_widget' ),
		'edit_item'                  => __( 'Edit Categories', 'testimonials_widget' ),
		'update_item'                => __( 'Update Categories', 'testimonials_widget' ),
		'separate_items_with_commas' => __( 'Separate categories with commas', 'testimonials_widget' ),
		'search_items'               => __( 'Search Categories', 'testimonials_widget' ),
		'add_or_remove_items'        => __( 'Add or remove categories', 'testimonials_widget' ),
		'choose_from_most_used'      => __( 'Choose from the most used categories', 'testimonials_widget' ),
		'not_found'                  => __( 'Not Found', 'testimonials_widget' ),
	);
	$args = array(
		'labels'                     => $labels,
		'hierarchical'               => false,
		'public'                     => true,
		'show_ui'                    => true,
		'show_admin_column'          => true,
		'show_in_nav_menus'          => true,
		'show_tagcloud'              => true,
		'rewrite'                    => false,
	);
	register_taxonomy( 'testimonial_cat', array( 'testimonials' ), $args );

}

// Hook into the 'init' action
add_action( 'init', 'sam_register_testimonial_taxonomy', 0 );

}