I have set up a custom post type with custom tags and categories.
I want to show posts by country AND by category and the categories need to be common to all countries. So if the user chooses a country from a drop down (or something) then all the categories of that country should be listed.
South Africa
- Sport
-- Golf
--- Irons
One option is to make the countries all PARENT categories with unique child categories for each country. But that will eventually get complicated and show looooong lists of duplicated category names in the post editor. Not a very smart way you’ll agree.
The other option I thought about was using Tags and Categories together, where the countries could be added as tags and the categories would then all be common. My question is how would I make a dynamic list of countries that will display the categories from a particular tag/country?
Is there maybe a simpler/better option you can suggest?
EDIT
@Mike Thanks for this. This is the route I have been playing with since posting the Q, kind of. I have set up a custom post type with a custom hierarchical taxonomy called Product Categories and another custom non-hierarchical taxonomy (tags) called Countries. I then created a new archive template that displays all the tagged posts. At the moment it displays all the tagged posts but what I am trying to get it to display is a list of categories in a tag instead… if that is at all possible. So say now I have two posts: 1. Brown Sneakers which is in the Category GOLF child of SPORT and tagged USA and 2. Pink shorts which is in the Category LADIES child of CLOTHING and tagged USA… when viewing USA tag page I would like to see as a list CLOTHING and SPORT (with its sub cats of course). There are going t be many countries sharing categories like sport and clothing.
Since this quite old question ranked pretty high when I was researching the topic and does not really provide an answer, let me point these two solutions/threads out:
https://wordpress.stackexchange.com/questions/312324/rewrite-url-with-category-and-tag-combined-using-wp-rewrite
https://wordpress.stackexchange.com/questions/147820/browse-by-category-and-tags
I would use custom taxonomies. You’d want a taxonomy for each of your data types (country, sport, equipment, team, player, etc).
You’ll need to
register_taxonomy()
for each one, and you might want some hierarchical taxonomies, so you can kind of combine them into one:So, you’ll have to play around with the best solution for when to use a NEW taxonomy and when to just use a hierarchical taxonomy. As far as I know, you can accomplish the same thing either way.
Ways to organize your content:
For a hierarchical taxonomy, you have to add each sub-item manually
When adding a custom taxonomy, you can choose which post types to apply it to
As I was writing this, it occurred to me, there’s not a great way to create a custom taxonomy FROM the posts in a custom post type. I did a search and found http://wordpress.org/plugins/cpt-onomies/ this plugin, which might be helpful.
Good luck!