我想出了一个办法,虽然感觉有点不对。
首先测试是否存在分类法(至少第一次没有),然后将其作为流程的一部分创建…
if (! taxonomy_exists($this->taxonomy_manufacturer)) {
register_taxonomy($this->taxonomy_manufacturer, \'product\');
}
if (! term_exists($manufacturer[\'name\'], $this->taxonomy_manufacturer)) {
wp_insert_term($manufacturer[\'name\'], $this->taxonomy_manufacturer);
}
注意事项,
register_taxonomy 警告
impending doom 如果是在
init. 我不确定它在我的场景中的含义,如果我的蜘蛛感觉开始刺痛,我会报告,但目前为止还不错。