I have a custom post type called produce
set up in WordPress and a custom taxonomy called produce_category
.
The URL format for posts in this custom post type is in this format http://mywebsite/produce/%produce_category%/%postname%/
. Of course %produce_category%
and %postname%
get substituted accordingly, a working example url would be http://mywebsite/produce/fruits-and-vegetables/avocado
.
What I would like to do is show the produce_category custom taxonomy archive if a user visits http://mywebsite/produce/%produce_category%
, without specifying post name at the end, e.g http://mywebsite/produce/fruits-and-vegetables
to show all produce in fruits-and-vegetables produce_category.
Besides that when a user visits http://mywebsite/produce/
I would like to show all the produce archive. EDIT: I have this working now.
I know how to create the archive pages totally fine and have no problem with that. I am stuck at creating permalinks. When I visit http://mywebsite/produce/%produce_category%
I get a 404 error.
I'm looking for advise on the best way to implement this. Currently I am using Custom Post Type Permalinks and CPTUI.
The CPTUI custom taxonomy settings interface does not allow me to have a blank in the custom rewrite slug. It defaults to the custom taxonomy slug, produce_category
, when I don't fill in anything.
This gives the front-side produce_category taxonomy archive url as http://mywebsite/produce/produce_category/%produce_category%/
e.g. http://mywebsite/produce/produce_category/fish-and-seafood/
when what I want for the archive is http://mywebsite/produce/fish-and-seafood/
.
Please help with suggestion on the best way I can achieve the custom taxonomy url.
Thank you all.