⚡ Target:
phpMyAdmin / WP-CLI db query
🔒 Tested: MySQL 8.0+ / MariaDB 10.4+
💻 Lang: SQL
⚠️ Database Table Prefix Reminder: This query uses the standard
wp_ table prefix (e.g. wp_options, wp_postmeta). If your installation uses a custom table prefix (configured in wp-config.php, e.g. wp_a7b_), be sure to replace wp_ with your custom prefix before running this query.
When posts or custom post types are deleted without proper cleanup hooks, their metadata remains in wp_postmeta. This query cleans orphaned post meta.