Opened 10 years ago
Closed 9 years ago
#32533 closed defect (bug) (worksforme)
wp_delete_post() is not deleting "wp_term_relationships"
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.2.2 |
Component: | Taxonomy | Keywords: | needs-patch reporter-feedback close |
Focuses: | Cc: |
Description
I am working with custom post types and custom taxonomy, recently i need to delete unwanted posts from the database.
I used wp_delete_post() function with the second argument was "true" to delete the post and all the related data to that particular post.
But I found that it is not deleting the data from the "wp_term_relationships" table clearly notice that it is happens with "custom taxonomy" made for the "custom post types".
Change History (6)
#5
@
10 years ago
- Keywords reporter-feedback close added
- Severity changed from major to normal
This sounds like the Custom Taxonomies were not registered at the time of deletion, or not attached to the post type correctly.
wp_delete_post()
calls wp_delete_object_term_relationships($postid, get_object_taxonomies($post->post_type));
as part of it's deletion process.
Changing this behaviour is not really possible at present, as we do not store the object-type in the term_relationships table. We have no idea if TaxA + Object123 is Post 123 or User 123 if TaxA is not attached to the post_type.
Can you duplicate the issue you saw? Can you confirm that the taxomies were registered at that time?
I also forgot to mention that when add any post in "custom post type" assigned any "term" of the "custom taxonomy" to test this issue.