4

I have a car database that I want to import into Wordpress as taxonomies. The problem is I can't create 2 taxonomies at once (first is parent, last ones are childs of first).

$p = wp_insert_term("Acura", "classified-category", array("description" => "Acura"));
$c = wp_insert_term("Acura CL", "classified-category", array("parent" => $p["term_id"], "description" => "Acura CL"));
print_r($p);
print_r($c);

returns:

Array ( [term_id] => 13 [term_taxonomy_id] => 4720 ) 
Array ( [term_id] => 2589 [term_taxonomy_id] => 4721 ) 

But in Dashboard appears just parent category. The problem is similar to this one: https://wordpress.stackexchange.com/questions/23125/create-two-categories-at-once-parent-child

Any idea ?

1 Answer 1

7

The issue is with the taxonomy cache. You have to clear it after you insert the terms in order to see them. I had the same issue, which someone answered for me here:

delete_option("classified-category_children");

Insert that after the term inserts and you should be good.

3
  • works great! thx! Commented Jul 30, 2011 at 16:01
  • Glad I was able to help out Commented Jul 30, 2011 at 20:38
  • Awesome. Worked perfectly.
    – Foxinni
    Commented Jun 25, 2013 at 11:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.