Opened 18 years ago
Closed 18 years ago
#4500 closed defect (bug) (fixed)
wp_update_term_count is not increasing taxonomy count correctly.
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 2.3 | Priority: | normal |
Severity: | major | Version: | 2.3 |
Component: | Administration | Keywords: | has-patch |
Focuses: | Cc: |
Description
It appears that wp_set_object_terms is not always increasing the taxonomy count. When using the following code, the count is not increased:
register_taxonomy('podcast_format', 'custom_field');
wp_insert_term('Main Feed', 'podcast_format'); Run only once to create term
wp_set_object_terms($custom_field_id, 'main-feed', 'podcast_format', false);
I am aware of wp_update_term_count, but shouldn't wp_set_object_terms increase the count for us?
Attachments (1)
Change History (4)
Note: See
TracTickets for help on using
tickets.
I've tracked down the problem. wp_update_term_count is checking if $taxonomy->update_count_callback is set to a custom update function. The problem is $taxonomy->update_count_callback is always set to a default value of null. My attached patch also checks to see if the $taxonomy->update_count_callback is not set to null.
In addition, even once you get past that step, the actual update function needed to be in a foreach loop. My attached patch corrects this issue also.
Finally, I would just like to clarify that this not only affects custom taxonomies, but the taxonomy link_category also. link_category is not using a custom update function, therefore falls into this defect.