Custom Taxonomy Only Showing Top Level Terms in Admin?

I have a hierarchical custom taxonomy that I add terms to programatically using the following code in a loop:

-- SNIP --
    $args = array(
        'description'=> '',
        'slug' => str_replace(' ','-',preg_replace('/[^\00-\255]+/u', '', $term)),
        'parent' => $parent
      );

    $term_id = wp_insert_term(
      $term, 
      'widgets', 
      $args
    );
-- SNIP --

Which works ok in terms of adding the widget terms in the desired hierarchical structure, however, on the taxonomy management page in admin, there is some really strange behavior. Only the top-level terms are shown in the list (2) even though it says 28 items found and there are pagination links for page 2 which displays nothing.

If I delete the top level terms, the second level is shown in the listing, etc.

Any ideas as to why this is happening and how to resolve would be appreciated.

1 Answer
1

I encountered a very similar situation, and I believe it may very well be the same situation you are experiencing. Please read the WPSE question Programmatically insert hierarchical terms & set terms for post causes glitch? and follow up with the answer provided by @Manny Fleurmond.

Leave a Comment