Build Term Relationship after wp_insert_term

Working on a project with migrating some data to a WordPress database I got my long and precise script up and running, but the data wasn’t visible in the taxonomy list view in the admin – only the parent term there, few pages of data calculated (pagination on), but no data other than the parent.

Luckily I found a cache wiping solution by Matt Thiessen (major props to the guy) who replied that a DB cache wipe could help by deleting the children option for the taxonomy in the DB, in a similar way (snippet from the link):

[php]
wp_insert_term( $new_name, $my_taxonomy, array( ‘parent’=> (int)$new__term_id ) );
delete_option($my_taxonomy.”_children”); // clear the cache
[/php]

Later this week I’ll post a snippet for switching to another WordPress database in the middle of a plugin. There are some solutions online, but they don’t seem to work in some cases, for example if you have different database table prefixes or so.

Leave a Reply

Your email address will not be published. Required fields are marked *