https://wordpress.stackexchange.com/questions/294003/custom-post-type-taxonomy-url-structure
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
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 ), ) ); } |