I have the following case:
'storage_type' => 'custom_table'.
When I delete any term of that custom taxonomy, the meta row of that term is not getting deleted from the custom table.
I don't face this issue with custom post types, it only happens with the custom taxonomies. The difference here is that deleted posts are being sent to the trash first, and when I delete that post permanently, its metadata that's stored in the custom table is getting deleted. But in the case of taxonomies, terms are being permanently deleted directly, there's no trash for terms.
But in the case of taxonomies, terms are being permanently deleted directly, there's no trash for terms.
It's the standard behavior of WordPress itself, the term will be deleted permanently instead of moving to the trash like the post.
I think because of this difference then the term meta in the custom table is also not deleted with the term. If you want to delete the term meta in the custom table, please use the supported API
delete(), read more on the documentation https://docs.metabox.io/extensions/mb-custom-table/#delete
Thank you, Peter, for your prompt reply!
I know that WordPress doesn't trash the terms; it deletes them directly. I only mentioned that as a possible reason that the term metadata is not being deleted from the custom table after deleting the term itself.
I will rephrase my question; I have a custom taxonomy that has some custom fields stored in a Custom Table; when I delete a term of that taxonomy, the row that stores the metadata of the deleted term is not being deleted from the custom table.
I tried the same custom taxonomy and fields without using the custom table, and I found that the metadata stored in the default
wp_termmeta table is deleted automatically when the term is deleted.
So, there's an issue with the MB Custom Table plugin; it doesn't handle deleting the metadata of the deleted term. And I think it's something that the plugin should take care of because it's the natural behavior of WordPress to delete the metadata of the deleted term.
I hope my question is clear now.
Thanks for your additional information.
Yes, I see that issue that's why I recommend using the public API
delete() to delete the row in the custom table. I've also escalated this issue to the development team to fix it in the next update.
And this issue was resolved after updating the plugin, thank you so much!
Thanks for the confirmation.
Let me know if you have any questions.