- This topic has 8 replies, 3 voices, and was last updated 3 years, 3 months ago by Tom.
July 2, 2018 at 8:44 am #613509Andy
Although this isn’t strictly related to GP I was hoping it would be ok to ask the question here as I will be using GP for the build. Basically I’m wondering what the best way is to categorize a site that needs to use the same sub-categories across different parent categories.
So for example if you had a Movie review website with the category/sub-category hierarchy as below:
Wordpress doesn’t allow you to do this because you can’t have 2 sub-categories with the same slug/URL. I know I could just rename the category slugs slightly but I think that can look rather messy and ugly. I know there are plugins that will ‘hack’ the permalink system to allow duplicate category URLs but I was hoping there would be a better way.
One solution I thought of was to make each sub-category a parent category and then only show posts that from BOTH categories. I’ve used the excellent WP Show Posts plugin in the past to display posts from certain categories but I’m not sure if the plugin shows posts from EITHER categories or BOTH. So I would have to create some custom category archives and use some kind of if statement from the WordPress Codex to achieve this.
But would this solution work and scale well as the site grows, how do you approach this problem and is there a better way?.July 2, 2018 at 1:58 pm #613771DavidStaffCustomer SupportJuly 2, 2018 at 2:56 pm #613799Andy
Thanks for the informative reply. So will WordPress allow duplicate sub-categories across different CPTs even if their URLs are the same?.
Do you think my solution mentioned previously is a viable option? I’ll have a look into PODs too but I’d prefer to avoid going down the plugin route, incase 12months-2years down line and after 100’s of posts they stop supporting and developing the plugin.July 2, 2018 at 3:01 pm #613802DavidStaffCustomer Support
I am no expert on this but i think the CPT work around would be to create Post types instead of Parent Categories. Then the sub category problem goes away. Its just a case of adding them all to the loop.July 2, 2018 at 3:08 pm #613803Andy
I’ve created CPTs before so I have a bit of experience with them, but if I created a CPT called ‘DVDs’ and then another CPT called ‘Cinema’ I would then need ‘Action’, ‘Scifi’ categories in both CPTs.
Maybe Tom could comment on this?July 2, 2018 at 3:18 pm #613804DavidStaffCustomer SupportJuly 2, 2018 at 7:37 pm #613879TomLead DeveloperLead Developer
As long as they belonged to different taxonomies, you should be able to use the same names.
Of course, it depends on how you structure the URL of the taxonomies.July 3, 2018 at 4:33 am #614182Andy
ok so just to clarify the URL’s of the taxonomies can also be the same?July 3, 2018 at 9:48 am #614535TomLead DeveloperLead Developer
Not exactly the same, no. That would confuse WP.
The taxonomies would have to be different in order to make the URL different.
- You must be logged in to reply to this topic.