Question

I'm adding product categories dinamically by code and it all works great (importing products from xml file), but for some reason when i get 46 product categories i cannot add anymore automatically and i can't find any reason why this happens.

The 47th category is added to the database and has all the needed information just like all others. It just doesnt appear in the product categories, and therefore not in the site's menu aswell. The confusing things are:

  1. It appears in the "Appearance > menu" listing with correct relationship with his parent
  2. The product categories says it lists 47 items but i can only count 46
  3. The 47th only appears if i delete all categories
  4. The query that shows product categories is correct

What is going on here? Can any one give me some clue about where should i search to fix this?

Thanks in advance.

Était-ce utile?

La solution

Finally i found the problem.

First, the problem had nothing to do with maximum number of categories or any sort of category limitations. It was a caching bug.

In my specific case, i added 46 terms at once and the plugin created a cache that holds all the children from my taxonomy. Later when i tried to add the 47th term, it was actually added correctly, but the cache was never updated for some reason and it's the reason for all the trouble.

The solution: Clear that cache by deleting the {$taxonomu}_children option.

delete_option("{$taxonomy}_children");

More on this:

inserting-terms-in-an-hierarchical-taxonomy

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top