下面是我正在做的事情:
create_taxonomy_record(array(
\'Label\',
\'tax_parent_slug\',
\'Label Related\',
\'this_tax_term_slug\'));
/* ---> Create a child */
create_taxonomy_record(array(
\'Label 2\',
\'this_tax_term_slug\',
\'Label Related\',
\'this_tax_term_slug_a_child\'));
这是一个名为create_taxonomy_record
(非常普通-echos用于调试目的)create_taxonomy_record($args)
{
$term = term_exists($args[0], $args[1]);
if ($term == 0 || $term == null) {
wp_insert_term(
$args[0], // the term
$args[1], // the taxonomy
array(
\'description\'=> $args[2],
\'slug\' => $args[3],
\'parent\'=> $args[1]
)
);
}
else { echo "<h1>" . $args[0] . " exists in parent " . $args[1] ."</h1>";}
}
所以这是行不通的,但失败也不难。我在上有警告/错误,而此代码两者都不提供。What\'s Working:
<分类法中的所有第一层术语都注册良好(1->n,我已经对该函数的10k个调用运行了测试,所有调用都名义上执行)What\'s Not Working:
<当我尝试将子术语指定给父术语时。我没有得到警告、失败或虚假的存在匹配,我只是什么都没有得到Now I did find this :Inserting terms in an Hierarchical Taxonomy
然而,这似乎并没有解决这个问题。或者更确切地说,我可能是在错误地清除缓存。我试图清除缓存的内容如下所示:
create_taxonomy_record(array(
\'Label\',
\'tax_parent_slug\',
\'Label Related\',
\'this_tax_term_slug\'));
/* ---> Create a child */
/* Tried it here */
delete_option("this_tax_term_slug_children");
create_taxonomy_record(array(
\'Label 2\',
\'this_tax_term_slug\',
\'Label Related\',
\'this_tax_term_slug_a_child\'));
/* and here - all permutations/ combinations should be considered attempted */
delete_option("this_tax_term_slug_children");
没有骰子。