Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

CPT Recipe – Taxonomy Ingredients

if ( ! function_exists( 'wpbscook_register_taxonomy_recipe_ingredients' ) ) {

// Register Custom Taxonomy
function wpbscook_register_taxonomy_recipe_ingredients() {

	$labels = array(
		'name'                       => _x( 'Ingredients', 'Taxonomy General Name', 'wpbscook' ),
		'singular_name'              => _x( 'Ingredient', 'Taxonomy Singular Name', 'wpbscook' ),
		'menu_name'                  => __( 'Ingredients', 'wpbscook' ),
		'all_items'                  => __( 'All ingredients', 'wpbscook' ),
		'parent_item'                => __( 'Parent ingredient', 'wpbscook' ),
		'parent_item_colon'          => __( 'Parent ingredient:', 'wpbscook' ),
		'new_item_name'              => __( 'New ingredient name', 'wpbscook' ),
		'add_new_item'               => __( 'Add new ingredient', 'wpbscook' ),
		'edit_item'                  => __( 'Edit ingredient', 'wpbscook' ),
		'update_item'                => __( 'Update ingredient', 'wpbscook' ),
		'separate_items_with_commas' => __( 'Separate ingredients with commas', 'wpbscook' ),
		'search_items'               => __( 'Search ingredients', 'wpbscook' ),
		'add_or_remove_items'        => __( 'Add or remove ingredients', 'wpbscook' ),
		'choose_from_most_used'      => __( 'Choose from the most used ingredients', 'wpbscook' ),
		'not_found'                  => __( 'Not Found', 'wpbscook' ),
	);
	$rewrite = array(
		'slug'                       => 'recipe_ingredient',
		'with_front'                 => true,
		'hierarchical'               => false,
	);
	$args = array(
		'labels'                     => $labels,
		'hierarchical'               => false,
		'public'                     => true,
		'show_ui'                    => true,
		'show_admin_column'          => true,
		'show_in_nav_menus'          => true,
		'show_tagcloud'              => true,
		'rewrite'                    => $rewrite,
	);
	register_taxonomy( 'wpbscook_ingredient', array( 'wpbscook_recipe' ), $args );

}

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

}