Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This question already has an answer here:

I am inserting an array of terms into my custom taxonomy programmatically. Some terms have parents/children. After each term has been entered, I then insert an array of posts into my custom post type. After inserting each post, I then set each post to it's proper taxonomy terms (parent terms and child terms).

After that entire sequence completes, when I navigate to the custom taxonomy management page. (Ex: ./edit-tags.php?taxonomy=my_custom_taxonomy&post_type=my_custom_post_type) It only shows the parent terms, with the number of posts in those parent terms.

None of the child terms show up.

If I edit a post from the custom post type, it shows that it has the proper parent/child terms selected.

Here's the strange part. If I edit one of the parent terms from the taxonomy management page and don't change anything, just click update. All of the sudden, all of my parent and children terms show up correctly.

It seems like WordPress should be flushing all these cached items automatically when these tasks are executed, but it's not.

Is this a WordPress bug? Am I doing something wrong, or forgetting to do something?

share|improve this question
add comment

marked as duplicate by Rarst Jul 19 '13 at 18:30

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

up vote 1 down vote accepted

I asked the same question a while ago. Scribu gave me an answer here.

The long and short of it: after you insert your terms, add this line of code.

delete_option("my_custom_taxonomy_children");

Of course, replace my_custom_taxonomy with your own, but leave the _children part.

share|improve this answer
add comment

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