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

Jak wyświetlić liczbę zapytań i czas wczytywania strony w WordPress?

Jeden z naszych użytkowników zapytał, w jaki sposób inne witryny pokazują liczbę zapytań i czas wczytywania strony w stopce. Często można to zobaczyć w stopce witryn i może to być coś w stylu: „64 zapytania w 1,248 sekundy”. W tym artykule pokażemy, jak wyświetlić liczbę zapytań i czas wczytywania strony w WordPress.

Wystarczy wkleić poniższy kod w dowolnym miejscu w plikach twojego motywu (np. footer.php).

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

.

I odświeżyć stronę. Zobaczysz liczbę zapytań i czas wykonania.

Ujawnienie: Nasze treści są wspierane przez czytelników. Oznacza to, że jeśli klikniesz na niektóre z naszych linków, możemy otrzymać prowizję. Zobacz jak WPBeginner jest finansowany, dlaczego to ma znaczenie i jak możesz nas wspierać. Oto nasz proces redakcyjny.

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.

Najlepszy zestaw narzędzi WordPress

Uzyskaj BEZPŁATNY dostęp do naszego zestawu narzędzi - zbiór produktów i zasobów związanych z WordPressem, które każdy profesjonalista powinien mieć!

Reader Interactions

7 komentarzyZostaw odpowiedź

  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

      Administrator

  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.

      Administrator

Zostaw odpowiedź

Dziękujemy za pozostawienie komentarza. Pamiętaj, że wszystkie komentarze są moderowane zgodnie z naszymi polityka komentarzy, a Twój adres e-mail NIE zostanie opublikowany. NIE używaj słów kluczowych w polu nazwy. Przeprowadźmy osobistą i konstruktywną rozmowę.