I’ve got a vexing how-to that I’ve not found any help on. I have a custom post type that has a custom field with a date in it (format: yyyy-mm-dd-t). When a post is published or edited, I would like to have a function that automatically populates a hierarchical taxonomy with the year and date.
So for example, if I entered “2003-03-15-1” into the custom date field, I would like it to include the custom taxonomy “2003” and its child taxonomy “03”. But while I’ve seen code that will populate the parent taxonomy, I’ve not found anything that tells me how to populate the parent and the child.
Surely such a thing is possible, right?
IF it were me, I would make “Year” and “Month” separate taxonomies rather than using a hierarchical taxonomy. If you do it that way, here’s a good answer to use as a reference. This will solve the “unique slug” issues you’ll run into using hierarchical taxonomies.