Uninstall plugin: delete events and postmeta from database
-
Hi,
When I uninstall my plugin I want to remove all events (custom post type) and event postmeta from database. I use this code in uninstall.php for that:
// Delete events + metadata global $wpdb; $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'event' );" ); $wpdb->query( "DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;" );
Taken from Woocommerce, and it works like a charm.
My question: the second query removes the event postmeta, but I don’t understand how it’s part of the first query? I mean, why does it only remove postmeta from events and not from all posts?Guido
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Uninstall plugin: delete events and postmeta from database’ is closed to new replies.