Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
Coppa WPB
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.

Divulgazione: I nostri contenuti sono sostenuti dai lettori. Ciò significa che se cliccate su alcuni dei nostri link, potremmo guadagnare una commissione. Vedi come WPBeginner è finanziato , perché è importante e come puoi sostenerci. Ecco il nostro processo editoriale .

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.

Il kit di strumenti WordPress definitivo

Ottenete l'accesso gratuito al nostro kit di strumenti - una raccolta di prodotti e risorse relative a WordPress che ogni professionista dovrebbe avere!

Reader Interactions

7 commentiLascia una risposta

  1. Syed Balkhi

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Pattrick

    How can i display only the load Time ?

    • WPBeginner Support

      You would move the echo to after the get_num_queries

      Admin

  3. 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.

  4. 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

Lascia una risposta

Grazie per aver scelto di lasciare un commento. Tenga presente che tutti i commenti sono moderati in base alle nostre politica dei commenti e il suo indirizzo e-mail NON sarà pubblicato. Si prega di NON utilizzare parole chiave nel campo del nome. Avremo una conversazione personale e significativa.