Im trying to pre-populate a custom taxonomy with regions, but am having trouble handling the multi dimensional array required for a hierarchical category.
At the moment I have a simple plugin that creates the taxonomy (loosely based on: https://github.com/curtismchale/WP-Theme-Tutorial---US-States-Plugin-for-WordPress)
The listing I would like to create looks something like:
-- North East
- North West
-- North America
If your code it was built upon a plugin like the git example, that would make it easier for me to test.
An example array that could generate the above example
A function that iterates over this array and
- Check that the entry does not already exist
- Add the entries to the taxonomy under the appropriate parent
Also, multidimensional arrays can be tricky (which is why I'm here) so if you want to recommend a different approach im open as long as it is easy to read and and concise.
I've been looking at the following plugin example for a flat list (git example post):
And have noted this SE topic about a WP caching bug when inputting a hierarchical taxonomy
I have modified a plugin please check it.
Please note you should first delete old texonomy created by the old plugin.
Let me know if you have any trouble.
Attaching image of output of above plugin.