Terms meta are not being deleted after deleting the term
- This topic has 5 replies, 2 voices, and was last updated 2 years, 4 months ago by
Peter.
-
AuthorPosts
-
November 18, 2022 at 5:41 PM #39203
Alaan TV
ParticipantI have the following case:
- A custom taxonomy
channel
. - Custom fields attached with the previous custom taxonomy.
- I'm storing the custom fields in a custom table
'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.
November 18, 2022 at 11:06 PM #39206Peter
ModeratorHello Alaan,
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/#deleteNovember 19, 2022 at 4:26 AM #39210Alaan TV
ParticipantThank 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.
November 20, 2022 at 10:34 AM #39226Peter
ModeratorThanks 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.December 6, 2022 at 7:45 AM #39523Alaan TV
ParticipantAnd this issue was resolved after updating the plugin, thank you so much!
December 6, 2022 at 11:11 PM #39562Peter
ModeratorThanks for the confirmation.
Let me know if you have any questions. - A custom taxonomy
-
AuthorPosts
- You must be logged in to reply to this topic.