Displaying Number of Queries and Page load time in WP

WordPress has some amazing built-in functionality. One such functionality is to be able to display the number of database queries made, along with displaying the number of seconds it took while loading any give page.

We can easily achieve this using two different function. First one is get_num_queries function, to display the number of queries. Second one is timer_stop function to display the seconds.

So, if you want to display this little piece of information to your site visitors, Here is the snippet:

<?php 
echo get_num_queries();  
echo ' queries in '; 
timer_stop(1); 
echo ' seconds.'; 
?>

Simply copy it, and paste it anywhere on your template’s file. My personal suggestion would be to use it on your template’s footer.php page.

Today In History

  •  
  •  

Comment

Leave a Reply

Note: Convet HTML, PHP, JavaScripts from Postable, before posting from comment section.
License: By submitting a comment here you grant this site a perpetual license to reproduce your words and name/Web site in attribution. Please use your real name or a pseudonym (i.e., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.