Hey edit my code and change it according to your needs
Here it is complete example of custom post and save the post.
<?php
/******************************************************Custom Recipe Post Type************************************************************************/
add_action( 'init', 'register_cpt_Recipe' );
function register_cpt_Recipe() {
$labels = array(
'name' => _x( 'All Recipe', 'Recipe' ),
'singular_name' => _x( 'All Recipe', 'Recipe' ),
'add_new' => _x( 'Add New Recipe', 'Recipe' ),
'add_new_item' => _x( 'Add New Recipe', 'Recipe' ),
'edit_item' => _x( 'Edit Recipe', 'Recipe' ),
'new_item' => _x( 'New Recipe', 'Recipe' ),
'view_item' => _x( 'View Recipe', 'Recipe' ),
'search_items' => _x( 'Search Recipe', 'Recipe' ),
'not_found' => _x( 'No Recipe found', 'Recipe' ),
'not_found_in_trash' => _x( 'No Recipe found in Trash', 'Recipe' ),
'parent_item_colon' => _x( 'Parent Recipe:', 'Recipe' ),
'menu_name' => _x( 'All Recipe', 'Recipe' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes' ),
'taxonomies' => array( 'category', 'post_tag', 'page-category' ),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'post',
'taxonomies' => array('recipe_type')
);
register_post_type( 'Recipe', $args );
}
function add_recipe_type_taxonomies() {
register_taxonomy('recipe_type', 'review', array(
// Hierarchical taxonomy (like categories)
'hierarchical' => true,
// This array of options controls the labels displayed in the WordPress Admin UI
'labels' => array(
'name' => _x( 'Recipe Category', 'taxonomy general name' ),
'singular_name' => _x( 'Recipe-Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Recipe-Categories' ),
'all_items' => __( 'All Recipe-Categories' ),
'parent_item' => __( 'Parent Recipe-Category' ),
'parent_item_colon' => __( 'Parent Recipe-Category:' ),
'edit_item' => __( 'Edit Recipe-Category' ),
'update_item' => __( 'Update Recipe-Category' ),
'add_new_item' => __( 'Add New Recipe-Category' ),
'new_item_name' => __( 'New Recipe-Category Name' ),
'menu_name' => __( 'Categories' ),
),
// Control the slugs used for this taxonomy
'rewrite' => array(
'slug' => 'recipe_type', // This controls the base slug that will display before each term
'with_front' => false, // Don't display the category base before "/locations/"
'hierarchical' => true // This will allow URL's like "/locations/boston/cambridge/"
),
));
}
add_action( 'init', 'add_recipe_type_taxonomies', 0 );