这在我看来确实像个虫子。我为您编写了以下代码,以便在新安装上对其进行测试。基本上,代码将在“未分类”下添加两个子类别,以实现以下效果
uncategorized
sub-uncategorized
sub-sub-uncategorized
将它们添加到wp\\U terms和wp\\U term\\u分类中没有问题。已正确添加两个父ID。
问题出在wp管理ui中。您只能看到未分类和子未分类。最后一个(sub-sub)在运行中丢失!
但是,如果您在同一个“添加类别”页面上转到父下拉选择,您将看到子uncat和“子sub cat”都出现在那里,并正确缩进-完全出现在以下正确的层次结构中
uncategorized
sub-uncategorized
sub-sub-uncategorized
要将缺少的sub-sub-cat引入主视图,必须执行以下步骤之一;
您可以通过停止和启动来回收wp。
或者简单地添加一只假猫,然后单击“类别”链接列出所有猫。然后wp记住正确显示SUB。
有人知道为什么会这样吗?
我很感激任何有计划的补救措施,这样我就不必经历愚蠢的步骤,而不仅仅是为了让猫进入视野。
代码如下所示。只需调整wp负载即可。php路径,然后才能在新安装上测试它,然后自己检查上面所述的内容。
<?php
error_reporting (E_ALL);
//load the wp shebang into this page
include (" put the full path here to the wp-load.php");
define(\'WP_USE_THEMES\', false);
//add a sub category under the "uncategorized" that fresh install comes with
$Term = "Sub-UnCategorized";
$args = array(\'parent\' => 1 );
wp_insert_term($Term, "category", $args);
//add another sub under the recentyl created above.
$Term = "Sub-Sub-UnCategorized";
$args = array(\'parent\' => 3 );
wp_insert_term($Term, "category", $args);
echo "<pre>
After running this code, you will notice that the Sub-Sub-UnCategorized is missing from the view.
But what\'s funny is the dropdown.
Check the dropdown for the *parent* selection, you will see that the missing
Sub-Sub-UnCategorized is there.
In order to get the missing sub-sub into the view, you will have to do two things.
1 - Add a dummy cat.
2 - Click on the categories link on the admin navigation.
With that, wp will sort this problem out and you will see everything you should have.
I cannot figure out what\'s causing this behavior and how to remedy this short adding the dummy cat and removing it later.
</pre>";
?>