Create mu-plugins folder in wp-content
Create plugin.php file in mu-plugins add following code in that file
now link your custom post type in plugin.php
Creating a function to create our Custom Post type (Product)
__( 'Products'),
'singular_name' => __( 'Product' ),
'menu_name' => __( 'Products' ),
'parent_item_colon' => __( 'Parent Product' ),
'all_items' => __( 'All Products' ),
'view_item' => __( 'View Product' ),
'add_new_item' => __( 'Add New Product' ),
'add_new' => __( 'Add New' ),
'edit_item' => __( 'Edit Product' ),
'update_item' => __( 'Update Product' ),
'search_items' => __( 'Search Product' ),
'not_found' => __( 'Not Found' ),
'not_found_in_trash' => __( 'Not found in Trash' ),
);
// Set other options for Custom Post Type
$args = array(
'label' => __( 'product' ),
'description' => __( 'Product' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', ),
'taxonomies' => array( 'genres' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'menu_icon' => 'dashicons-products',
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 99,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
'show_in_rest' => true,
);
// Registering your Custom Post Type
register_post_type( 'product', $args );
}
Creating a function to create our Custom Taxonomies for Prodcuts
_x( 'Delivery', 'taxonomy general name' ),
'singular_name' => _x( 'Delivery', 'taxonomy singular name' ),
'search_items' => __( 'Search Delivery' ),
'all_items' => __( 'All Delivery' ),
'parent_item' => __( 'Parent Delivery' ),
'parent_item_colon' => __( 'Parent Delivery:' ),
'edit_item' => __( 'Edit Delivery' ),
'update_item' => __( 'Update Delivery' ),
'add_new_item' => __( 'Add New Delivery' ),
'new_item_name' => __( 'New Delivery Name' ),
'menu_name' => __( 'Delivery' ),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_in_rest' => true,
'show_admin_column' => true,
'query_var' => true,
);
// Now register the taxonomy
register_taxonomy('delivery','product', $args);
}