Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

CHB – Fruits CPT

if ( ! function_exists('register_fruits_cpt') ) {

// Register Custom Post Type
function register_fruits_cpt() {

	$labels = array(
		'name'                => _x( 'Fruits', 'Post Type General Name', 'html5reset' ),
		'singular_name'       => _x( 'Fruit', 'Post Type Singular Name', 'html5reset' ),
		'menu_name'           => __( 'Fruits', 'html5reset' ),
		'parent_item_colon'   => __( 'Parent Fruit:', 'html5reset' ),
		'all_items'           => __( 'All Fruits', 'html5reset' ),
		'view_item'           => __( 'View Fruit', 'html5reset' ),
		'add_new_item'        => __( 'Add New Fruit', 'html5reset' ),
		'add_new'             => __( 'Add New', 'html5reset' ),
		'edit_item'           => __( 'Edit Fruit', 'html5reset' ),
		'update_item'         => __( 'Update Fruit', 'html5reset' ),
		'search_items'        => __( 'Search Fruit', 'html5reset' ),
		'not_found'           => __( 'Not found', 'html5reset' ),
		'not_found_in_trash'  => __( 'Not found in Trash', 'html5reset' ),
	);
	$args = array(
		'label'               => __( 'fruits', 'html5reset' ),
		'description'         => __( 'Fruit Post Type', 'html5reset' ),
		'labels'              => $labels,
		'supports'            => array( 'title', 'editor', 'thumbnail', ),
		'hierarchical'        => false,
		'public'              => true,
		'show_ui'             => true,
		'show_in_menu'        => true,
		'show_in_nav_menus'   => true,
		'show_in_admin_bar'   => true,
		'menu_position'       => 5,
		'can_export'          => true,
		'has_archive'         => true,
		'exclude_from_search' => false,
		'publicly_queryable'  => true,
		'capability_type'     => 'page',
	);
	register_post_type( 'fruits', $args );

}

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

}