如果其他人偶然发现了这种问题,下面是我的解决方案:(无需管理任何代谢箱等)
add_action(\'categorycourses_add_form_fields\',\'categorycourses_edit_form_fields\');
add_action(\'categorycourses_edit_form_fields\',\'categorycourses_edit_form_fields\');
//Function only showing parent categories when editing or adding new category-courses
function categorycourses_edit_form_fields() {
?>
<script type="text/javascript">
jQuery(document).ready( function($) {
var level = 1;
//Go down in hierarchy from level1 and remove each level until there are no levels anymore
//Don\'t do anything with level-0 because we want to show parent-categories
while ( level < $("form .form-field #parent").find(".level-" + level).length>0 ) {
$("form .form-field #parent").find(".level-1").remove(); //Remove level
}
});
</script>
<?php
}
(categorycourses是一种分类法,如果您希望使用代码,只需更改分类法,如
add_action(\'{taxonomy}_add_form_fields\',\'{taxonomy}_edit_form_fields\');
add_action(\'{taxonomy}_edit_form_fields\',\'{taxonomy}_edit_form_fields\');
()