check sql query executed wp code example
Example: check sql query executed wp
For $wpdb->queries to work you need to configure in wp-config.php:
define('SAVEQUERIES', true);
This is highly not recommended for production (heavy performance hit) and so
turned off by default.