Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Come mostrare il numero di query e il tempo di caricamento delle pagine in WordPress

Un utente ci ha chiesto come fanno altri siti a mostrare il numero di query e il tempo di caricamento della pagina nel footer. Spesso si può vedere questo dato nel footer dei siti, con una dicitura del tipo: “64 query in 1,248 secondi”. In questo articolo vi mostreremo come mostrare il numero di query e il tempo di caricamento della pagina in WordPress.

È sufficiente incollare il seguente codice in un punto qualsiasi dei file del tema (ad esempio footer.php).

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

E ricaricare la pagina. Verranno visualizzati il numero di query e il tempo di esecuzione.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

6 commentiLeave a Reply

  1. Pattrick

    How can i display only the load Time ?

    • WPBeginner Support

      You would move the echo to after the get_num_queries

      Admin

  2. Aidan

    You should make clear that the timer_stop() function only measures page load time, not how long the queries take to complete.
    These are often related, but the way you present the code makes it look like the queries are always related to the speed issues, and often they aren’t.

  3. Sean Donovan

    It would be useful to know what a typical number of queries are for a WordPress site running 10 or so plugins…

    • Editorial Staff

      Can’t say at all because each plugin varies. You can use 10 plugins that work entirely in the backend which will add no queries on the front-end load. Or 10 really horrible coded plugins that can add tons of queries on the front-end.

      Admin

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.