A WordPress user recently asked how popular sites show database query counts and page load times in their footers, like "64 queries in 1.248 seconds." As experienced WordPress developers, we've optimized countless sites and used this debugging technique for years. Here's a simple, reliable way to add it to your site.
Paste this proven code snippet into your active theme's footer.php file, ideally just before the closing </body> tag.
<?php
printf(
_n(
'%d query',
'%d queries',
$wpdb->num_queries
),
$wpdb->num_queries
);
echo ' in ' . timer_stop(0) . ' seconds.';
?>Save the file, refresh your page, and you'll see the real-time query count and execution time displayed—perfect for performance tuning and troubleshooting.