How to show number of WordPress queries and page load time

How to show number of WordPress queries and page load time

Heres a little nifty WordPress snippet that will show the number of queries made and the page load time. This can come in handy if you, for instance, need to debug or optimize the performance of your WordPress site.

Instructions
Add this code snippet to a template file during testing in the location where you want the info to show. In this example the output is wrapped in an “if user is administrator” condition – so that the output is only visible to users with administrator rights.

<?php if(current_user_can('administrator')): ?>
     <?php echo get_num_queries(); ?> queries in <?php timer_stop(1); ?> seconds.
<?php endif; ?>

Related links
http://www.livexp.net/wordpress/display-wordpress-page-loading-time-and-number-of-queries.html

WordPress Snippet Info

Tested with Wordpress v. 4.9.5
Last Modified: 15.05.2018
Last Reviewed: 15.05.2018

How to show number of WordPress queries and page load time
4.1 (82%) 10 vote[s]
Please report broken snippets.
Report Broken Snippet
WordPress Hosting