Created
July 15, 2020 18:07
-
-
Save unaibamir/e4b2f819f694f0c02ef17b4d0408925d to your computer and use it in GitHub Desktop.
lmsninjas custom post types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Register Products CPT | |
*/ | |
if ( ! function_exists('register_cpt_products') ) { | |
// Register Custom Post Type | |
function register_cpt_products() { | |
$labels = array( | |
'name' => _x( 'Products','wooninjas' ), | |
'singular_name' => _x( 'Product','wooninjas' ), | |
'menu_name' => __( 'Products', 'wooninjas' ), | |
'name_admin_bar' => __( 'Product', 'wooninjas' ), | |
'archives' => __( 'Product Archives', 'wooninjas' ), | |
'attributes' => __( 'Item Attributes', 'wooninjas' ), | |
'parent_item_colon' => __( 'Parent Item:', 'wooninjas' ), | |
'all_items' => __( 'All Products', 'wooninjas' ), | |
'add_new_item' => __( 'Add New Product', 'wooninjas' ), | |
'add_new' => __( 'Add Product', 'wooninjas' ), | |
'new_item' => __( 'New Product', 'wooninjas' ), | |
'edit_item' => __( 'Edit Product', 'wooninjas' ), | |
'update_item' => __( 'Update Product', 'wooninjas' ), | |
'view_item' => __( 'View Product', 'wooninjas' ), | |
'view_items' => __( 'View Products', 'wooninjas' ), | |
'search_items' => __( 'Search Product', 'wooninjas' ), | |
'not_found' => __( 'Not found', 'wooninjas' ), | |
'not_found_in_trash' => __( 'Not found in Trash', 'wooninjas' ), | |
'insert_into_item' => __( 'Insert into Product', 'wooninjas' ), | |
); | |
$args = array( | |
'label' => __( 'Product', 'wooninjas' ), | |
'labels' => $labels, | |
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'comments'), | |
'taxonomies' => array( 'wn_product_cats' ), | |
'hierarchical' => false, | |
'public' => true, | |
'show_ui' => true, | |
'show_in_menu' => true, | |
'menu_position' => 25, | |
'show_in_admin_bar' => true, | |
'show_in_nav_menus' => true, | |
'can_export' => true, | |
'has_archive' => true, | |
'exclude_from_search' => false, | |
'publicly_queryable' => true, | |
'rewrite' => array( 'slug' => 'wn-products' ), | |
'capability_type' => 'post', | |
); | |
register_post_type( 'wn_products', $args ); | |
} | |
add_action( 'init', 'register_cpt_products', 0 ); | |
} | |
/* | |
* Register MicroService Products CPT | |
*/ | |
if ( ! function_exists('register_cpt_service_products') ) { | |
// Register Custom Post Type | |
function register_cpt_service_products() { | |
$labels = array( | |
'name' => _x( 'MicroService','wooninjas' ), | |
'singular_name' => _x( 'MicroService','wooninjas' ), | |
'menu_name' => __( 'MicroServices', 'wooninjas' ), | |
'name_admin_bar' => __( 'MicroService', 'wooninjas' ), | |
'archives' => __( 'MicroService Archives', 'wooninjas' ), | |
'attributes' => __( 'MicroService Attributes', 'wooninjas' ), | |
'parent_item_colon' => __( 'Parent Item:', 'wooninjas' ), | |
'all_items' => __( 'All MicroService', 'wooninjas' ), | |
'add_new_item' => __( 'Add New MicroService', 'wooninjas' ), | |
'add_new' => __( 'Add MicroService', 'wooninjas' ), | |
'new_item' => __( 'New MicroService', 'wooninjas' ), | |
'edit_item' => __( 'Edit MicroService', 'wooninjas' ), | |
'update_item' => __( 'Update MicroService', 'wooninjas' ), | |
'view_item' => __( 'View MicroService', 'wooninjas' ), | |
'view_items' => __( 'View MicroServices', 'wooninjas' ), | |
'search_items' => __( 'Search MicroService', 'wooninjas' ), | |
'not_found' => __( 'Not found', 'wooninjas' ), | |
'not_found_in_trash' => __( 'Not found in Trash', 'wooninjas' ), | |
'insert_into_item' => __( 'Insert into MicroService', 'wooninjas' ), | |
); | |
$args = array( | |
'label' => __( 'MicroService', 'wooninjas' ), | |
'labels' => $labels, | |
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'comments'), | |
'taxonomies' => array( 'wn_microserve_cats' ), | |
'hierarchical' => false, | |
'public' => true, | |
'show_ui' => true, | |
'show_in_menu' => true, | |
'menu_position' => 25, | |
'show_in_admin_bar' => true, | |
'show_in_nav_menus' => true, | |
'can_export' => true, | |
'has_archive' => true, | |
'exclude_from_search' => false, | |
'publicly_queryable' => true, | |
'rewrite' => array( 'slug' => 'wn-microservices' ), | |
'capability_type' => 'post', | |
); | |
register_post_type( 'wn_microservices', $args ); | |
} | |
add_action( 'init', 'register_cpt_service_products', 0 ); | |
} | |
/* | |
* Register Categories for Product CPT | |
*/ | |
add_action( 'init', 'create_products_tax' ); | |
function create_products_tax() { | |
register_taxonomy( | |
'wn_product_cats', | |
'wn_products', | |
array( | |
'label' => __( 'Categories' ), | |
'rewrite' => array( 'slug' => 'products-cats' ), | |
'hierarchical' => true, | |
) | |
); | |
} | |
/* | |
* Register Categories for MicroServices CPT | |
*/ | |
add_action( 'init', 'create_microservice_tax' ); | |
function create_microservice_tax() { | |
register_taxonomy( | |
'wn_microserve_cats', | |
'wn_microservices', | |
array( | |
'label' => __( 'MicroService Categories' ), | |
'rewrite' => array( 'slug' => 'microservice-cats' ), | |
'hierarchical' => true, | |
) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment