Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**** Creating Custom Post *****////
- function create_post_type() {
- register_post_type( 'product',
- array(
- 'labels' => array(
- 'name' => __( 'Products' ),
- 'singular_name' => __( 'product' ),
- 'add_new' => __( 'Add Product' ),
- 'add_new_item' => __( 'Add Product' ),
- 'edit_item' => __( 'Edit Product' ),
- 'new_item' => __( 'New Product' ),
- 'view_item' => __( 'View Product' ),
- 'not_found' => __( 'Sorry, we couldn\'t find the Product you are looking for.' )
- ),
- 'public' => true,
- 'publicly_queryable' => true,
- 'exclude_from_search' => true,
- 'menu_position' => 19,
- 'menu_icon' => 'dashicons-cart',
- 'has_archive' => true,
- 'hierarchical' => true,
- 'capability_type' => 'post',
- 'rewrite' => array( 'slug' => 'product' ),
- 'supports' => array( 'title', 'editor', 'thumbnail' )
- )
- );
- }
- add_action( 'init', 'create_post_type' );
- /************ Taxonomy Area *************/
- function product_taxonomy() {
- register_taxonomy(
- 'product_cat', //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces).
- 'product', //post type name
- array(
- 'hierarchical' => true,
- 'label' => 'product Category', //Display name
- 'query_var' => true,
- 'show_admin_column' => true,
- 'rewrite' => array(
- 'slug' => 'product-category', // This controls the base slug that will display before each term
- 'with_front' => false // Don't display the category base before
- )
- )
- );
- }
- add_action( 'init', 'product_taxonomy');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement