Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Flora

Flora CPT for Aerstrum

if ( ! function_exists('register_flora') ) {

// Register Custom Post Type
function register_flora() {

	$labels = array(
		'name'                  => _x( 'Flora', 'Post Type General Name', 'text_domain' ),
		'singular_name'         => _x( 'Plant', 'Post Type Singular Name', 'text_domain' ),
		'menu_name'             => __( 'Flora', 'text_domain' ),
		'name_admin_bar'        => __( 'Flora', 'text_domain' ),
		'archives'              => __( 'Flora Archives', 'text_domain' ),
		'attributes'            => __( 'Flora Attributes', 'text_domain' ),
		'parent_item_colon'     => __( 'Parent Plant', 'text_domain' ),
		'all_items'             => __( 'All Flora', 'text_domain' ),
		'add_new_item'          => __( 'Add New Plant', 'text_domain' ),
		'add_new'               => __( 'Add New', 'text_domain' ),
		'new_item'              => __( 'New Plant', 'text_domain' ),
		'edit_item'             => __( 'Edit Plant', 'text_domain' ),
		'update_item'           => __( 'Update Plant', 'text_domain' ),
		'view_item'             => __( 'View Plant', 'text_domain' ),
		'view_items'            => __( 'View Flora', 'text_domain' ),
		'search_items'          => __( 'Search Flora', 'text_domain' ),
		'not_found'             => __( 'Not found', 'text_domain' ),
		'not_found_in_trash'    => __( 'Not found in Trash', 'text_domain' ),
		'featured_image'        => __( 'Featured Image', 'text_domain' ),
		'set_featured_image'    => __( 'Set featured image', 'text_domain' ),
		'remove_featured_image' => __( 'Remove featured image', 'text_domain' ),
		'use_featured_image'    => __( 'Use as featured image', 'text_domain' ),
		'insert_into_item'      => __( 'Insert into plant', 'text_domain' ),
		'uploaded_to_this_item' => __( 'Uploaded to this plant', 'text_domain' ),
		'items_list'            => __( 'Flora list', 'text_domain' ),
		'items_list_navigation' => __( 'Flora list navigation', 'text_domain' ),
		'filter_items_list'     => __( 'Filter flora list', 'text_domain' ),
	);
	$capabilities = array(
		'edit_post'             => 'edit_flora',
		'read_post'             => 'read_flora',
		'delete_post'           => 'delete_flora',
		'edit_posts'            => 'edit_floras',
		'edit_others_posts'     => 'edit_others_flora',
		'publish_posts'         => 'publish_flora',
		'read_private_posts'    => 'read_private_flora',
	);
	$args = array(
		'label'                 => __( 'Plant', 'text_domain' ),
		'description'           => __( 'Flora of Aerstrum Universe', 'text_domain' ),
		'labels'                => $labels,
		'supports'              => array( 'title', 'editor', 'thumbnail', 'comments', 'revisions', 'custom-fields', 'page-attributes' ),
		'hierarchical'          => true,
		'public'                => true,
		'show_ui'               => true,
		'show_in_menu'          => true,
		'menu_position'         => 5,
		'menu_icon'             => 'dashicons-palmtree',
		'show_in_admin_bar'     => false,
		'show_in_nav_menus'     => true,
		'can_export'            => true,
		'has_archive'           => true,
		'exclude_from_search'   => false,
		'publicly_queryable'    => true,
		'capabilities'          => $capabilities,
		'show_in_rest'          => true,
		'rest_controller_class' => 'WP_REST_Flora_Controller',
	);
	register_post_type( 'flora', $args );

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

}