"Category" based permalinks for custom "Products" post type
-
Hello,
I’ve created a custom post type using register_post_type called “products” which will be used for holding about 1000 different products. The products are assigned to categories such as “Bathroom furniture > storage” or “Taps”. I’ve got everything working nicely in the admin area but now i’m writing the templates i’m a bit stuck on how to achieve the permalink structure. Here’s what i’d like:
- /products – display an archive page of the complete product range (paginated)
- /products/CATEGORY – this would list all products in that category as well as any child sub-categories
- /products/CATEGORY/SUBCATEGORY – this would list all products in that sub-category
- /products/CATEGORY/SUBCATEGORY/PRODUCTSTUB – the actual product
I started off creating a template called archive-products.php to show the first view and that works fine.
Next I made single-products.php and that works fine for the 4th view.
The next thing I tried was changing the category base in the setting > permalinks section of the wp-admin area to “products”. This get’s me really close with views 1-3 all working perfectly but that breaks the 4th view.
Can anyone help me get the 4th view working?
Any help much appreciated!
Julian
- The topic ‘"Category" based permalinks for custom "Products" post type’ is closed to new replies.