If you are a WordPress theme developer, a WP Plugin Developer, or just a WordPress blog owner who is curious to know how much time WordPress takes to load any page on the website, then there’s a simple way to figure that out.
Adding a small code snippet to your footer.php file will display the number of seconds it took WordPress to generate the page you will be looking at. You can add the snippet anywhere an in any file you want, but adding it in the footer.php file will make sure that the other content on the page appears first.
<p>WordPress took <?php timer_stop(1); ?> seconds to load the page</p>
Related Articles
Taking it a little further, you can also display the number of queries processed by WordPress to generate the page.
<p>WordPress processed <?php echo get_num_queries(); ?> queries in <?php timer_stop(1); ?> seconds.</p>
If you want to hide the number of queries and the time taken to generate the page from your website visitors, then you can use the code below. It first check if you are logged into WordPress as administrator, and if yes, it will display the information.
<?php if ( current_user_can('manage_options') ) : ?>
<p>WordPress processed <?php echo get_num_queries(); ?> queries in <?php timer_stop(1); ?> seconds.</p>
<?php endif; ?>