Last active
September 26, 2022 07:48
-
-
Save nawawi/836132a39f1ea780b80927575af22a31 to your computer and use it in GitHub Desktop.
MySQL trigger to remove wp orphan post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Replace wp_postmeta and wp_posts with your prefix table | |
CREATE TRIGGER `remove_orphan_post` AFTER DELETE ON `wp_posts` | |
FOR EACH ROW BEGIN IF ('post' = old.post_type) THEN | |
DELETE FROM wp_postmeta WHERE wp_postmeta.post_id = old.ID; | |
END IF; END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment