On my site I have a Custom Post Type “listing” which has a hierarchial Taxonomy “local”.
The terms in this taxonomy are in the form of States > Cities.
For example “Washington” is a parent term & Arlington, Auburn, Davenport etc could be it’s child taxonomies.
Now when I export & import this Custom Post Type to another site, my child level taxonomies become top level taxonomies, they no longer retain the hierarchy.
I have used code in functions.php to create these, no plugins. What am I doing wrong?
I understand your problem and had to work around it as well:
wp_insert_term()
doesn’t handle parent/children connections.You can check this with the following:
You will see that it stays empty. The reason is simple: There’s an Option that holds this information. You’ll need to update it as well:
At first I didn’t get that the hierarchy didn’t work, but when you look at the taxonomy overview page in the admin UI, then you’ll see that the terms are not aligned like the should (in child/parent lists).