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.