Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

bus

// Register Custom Post Type
function io_business_post_type() {

	$labels = array(
		'name'                  => _x( 'Businesses', 'Post Type General Name', 'io_post_types' ),
		'singular_name'         => _x( 'Business', 'Post Type Singular Name', 'io_post_types' ),
		'menu_name'             => __( 'Businesses', 'io_post_types' ),
		'name_admin_bar'        => __( 'Businesses', 'io_post_types' ),
		'archives'              => __( 'Business Archives', 'io_post_types' ),
		'attributes'            => __( 'Business Attributes', 'io_post_types' ),
		'parent_item_colon'     => __( 'Parent Business:', 'io_post_types' ),
		'all_items'             => __( 'All Businesses', 'io_post_types' ),
		'add_new_item'          => __( 'Add New Business', 'io_post_types' ),
		'add_new'               => __( 'Add New', 'io_post_types' ),
		'new_item'              => __( 'New Item', 'io_post_types' ),
		'edit_item'             => __( 'Edit Business', 'io_post_types' ),
		'update_item'           => __( 'Update Business', 'io_post_types' ),
		'view_item'             => __( 'View Business', 'io_post_types' ),
		'view_items'            => __( 'View Businesses', 'io_post_types' ),
		'search_items'          => __( 'Search Business', 'io_post_types' ),
		'not_found'             => __( 'Not found', 'io_post_types' ),
		'not_found_in_trash'    => __( 'Not found in Trash', 'io_post_types' ),
		'featured_image'        => __( 'Featured Image', 'io_post_types' ),
		'set_featured_image'    => __( 'Set featured image', 'io_post_types' ),
		'remove_featured_image' => __( 'Remove featured image', 'io_post_types' ),
		'use_featured_image'    => __( 'Use as featured image', 'io_post_types' ),
		'insert_into_item'      => __( 'Insert into Business', 'io_post_types' ),
		'uploaded_to_this_item' => __( 'Uploaded to this Business', 'io_post_types' ),
		'items_list'            => __( 'Businesses list', 'io_post_types' ),
		'items_list_navigation' => __( 'Businesses list navigation', 'io_post_types' ),
		'filter_items_list'     => __( 'Filter Businesses list', 'io_post_types' ),
	);
	$rewrite = array(
		'slug'                  => 'business',
		'with_front'            => true,
		'pages'                 => true,
		'feeds'                 => true,
	);
	$args = array(
		'label'                 => __( 'Business', 'io_post_types' ),
		'description'           => __( 'Post type for businesses', 'io_post_types' ),
		'labels'                => $labels,
		'supports'              => array( 'title', 'editor', 'thumbnail', 'custom-fields', 'page-attributes', 'post-formats' ),
		'taxonomies'            => array( 'business-category', 'post_tag' ),
		'hierarchical'          => false,
		'public'                => true,
		'show_ui'               => true,
		'show_in_menu'          => true,
		'menu_position'         => 5,
		'menu_icon'             => 'plugin_dir_path( __FILE__ ).'/assets/icons/business-24px.svg'',
		'show_in_admin_bar'     => false,
		'show_in_nav_menus'     => true,
		'can_export'            => true,
		'has_archive'           => true,
		'exclude_from_search'   => false,
		'publicly_queryable'    => true,
		'rewrite'               => $rewrite,
		'capability_type'       => 'page',
		'show_in_rest'          => true,
	);
	register_post_type( 'business_post_type', $args );

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