Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Post Type Tenant

if ( ! function_exists('custom_post_type') ) {

// Register Custom Post Type
function custom_post_type() {

	$labels = array(
		'name'                  => _x( 'Tenants', 'Post Type General Name', 'text_domain' ),
		'singular_name'         => _x( 'Tenant', 'Post Type Singular Name', 'text_domain' ),
		'menu_name'             => __( 'Tenants', 'text_domain' ),
		'name_admin_bar'        => __( 'Tenants', 'text_domain' ),
		'archives'              => __( 'Tenant Archives', 'text_domain' ),
		'attributes'            => __( 'Tenant Attributes', 'text_domain' ),
		'parent_item_colon'     => __( 'Parent Tenant:', 'text_domain' ),
		'all_items'             => __( 'All Tenants', 'text_domain' ),
		'add_new_item'          => __( 'Add New Tenant', 'text_domain' ),
		'add_new'               => __( 'Add New Tenant', 'text_domain' ),
		'new_item'              => __( 'New Tenant', 'text_domain' ),
		'edit_item'             => __( 'Edit Tenant', 'text_domain' ),
		'update_item'           => __( 'Update Tenant', 'text_domain' ),
		'view_item'             => __( 'View Tenant', 'text_domain' ),
		'view_items'            => __( 'View Tenants', 'text_domain' ),
		'search_items'          => __( 'Search Tenant', 'text_domain' ),
		'not_found'             => __( 'Tenant Not found', 'text_domain' ),
		'not_found_in_trash'    => __( 'TenantNot 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 tenant', 'text_domain' ),
		'uploaded_to_this_item' => __( 'Uploaded to this tenant', 'text_domain' ),
		'items_list'            => __( 'Tenants List', 'text_domain' ),
		'items_list_navigation' => __( 'Tenant list navigation', 'text_domain' ),
		'filter_items_list'     => __( 'Filter Tenants list', 'text_domain' ),
	);
	$rewrite = array(
		'slug'                  => 'www.bloomproperties.co.za/tenants',
		'with_front'            => true,
		'pages'                 => true,
		'feeds'                 => true,
	);
	$capabilities = array(
		'edit_post'             => 'edit_tenant',
		'read_post'             => 'read_tenant',
		'delete_post'           => 'delete_tenant',
		'edit_posts'            => 'edit_tenants',
		'edit_others_posts'     => 'edit_others_tenants',
		'publish_posts'         => 'publish_tenants',
		'read_private_posts'    => 'read_private_tenants',
	);
	$args = array(
		'label'                 => __( 'Tenant', 'text_domain' ),
		'description'           => __( 'Post Type Description', 'text_domain' ),
		'labels'                => $labels,
		'supports'              => array( 'title', 'editor', 'thumbnail', 'comments', 'trackbacks', 'revisions', 'custom-fields', 'page-attributes', 'post-formats' ),
		'taxonomies'            => array( 'category', 'post_tag', 'tenant_type', 'tenant_property', 'tenant_lease', 'tenant_payments' ),
		'hierarchical'          => false,
		'public'                => true,
		'show_ui'               => true,
		'show_in_menu'          => true,
		'menu_position'         => 70,
		'menu_icon'             => 'dashicons-businessman',
		'show_in_admin_bar'     => true,
		'show_in_nav_menus'     => true,
		'can_export'            => true,
		'has_archive'           => 'tenant_archives',
		'exclude_from_search'   => false,
		'publicly_queryable'    => true,
		'query_var'             => 'tenant_type',
		'rewrite'               => $rewrite,
		'capabilities'          => $capabilities,
		'show_in_rest'          => true,
		'rest_base'             => 'post type key',
		'rest_controller_class' => 'WP_REST_Posts_Controller',
	);
	register_post_type( 'post_type', $args );

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

}