add_action( 'init', 'register_sps_products_post_type' );
function register_sps_products_post_type() {
register_post_type( 'sps-product',
array(
'labels' => array(
'name' => 'Products',
'menu_name' => 'Product Manager',
'singular_name' => 'Product',
'all_items' => 'All Products'
),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'comments', 'post-formats', 'revisions' ),
'hierarchical' => false,
'has_archive' => 'products',
'taxonomies' => array('product-category'),
'rewrite' => array( 'slug' => 'products/%product_category%', 'hierarchical' => true, 'with_front' => false )
)
);
register_taxonomy( 'product-category', array( 'sps-product' ),
array(
'labels' => array(
'name' => 'Product Categories',
'menu_name' => 'Product Categories',
'singular_name' => 'Product Category',
'all_items' => 'All Categories'
),
'public' => true,
'hierarchical' => true,
'show_ui' => true,
'rewrite' => array( 'slug' => 'products', 'hierarchical' => true, 'with_front' => false ),
)
);
}