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łączyć błędy PHP w WordPress

Uwaga redakcyjna: Otrzymujemy prowizję z linków partnerskich na WPBeginner. Prowizje nie mają wpływu na opinie i oceny naszych redaktorów. Dowiedz się więcej o Proces redakcyjny.

Niedawno jeden z naszych czytelników zapytał, jak wyłączyć błędy PHP w WordPress?

Ostrzeżenia i powiadomienia PHP pomagają programistom w debugowaniu problemów z ich kodem. Wygląda to jednak bardzo nieprofesjonalnie, gdy są one widoczne dla wszystkich odwiedzających twoją witrynę internetową.

W tym artykule pokażemy, jak łatwo wyłączyć błędy PHP w WordPress.

How to turn off PHP errors in WordPress

Dlaczego i kiedy należy wyłączyć błędy PHP w WordPress?

Błędy PHP, które możesz zobaczyć na swojej witrynie WordPress, to zazwyczaj ostrzeżenia i powiadomienia. Nie są to wewnętrzne błędy serwera, błędy składni lub błędy krytyczne, które uniemożliwiają wczytywanie twojej witryny internetowej.

Powiadomienia i ostrzeżenia to rodzaj błędów, które nie powstrzymują WordPressa przed wczytywaniem twojej witryny internetowej. Zobacz, jak WordPress działa za kulisami, aby uzyskać więcej szczegółów.

PHP errors in WordPress admin area

Celem tych błędów jest pomoc programistom w debugowaniu problemów z ich kodem. Twórcy wtyczek i motywów potrzebują tych informacji, aby sprawdzić zgodność [może być też „kompatybilny”].

Jeśli jednak nie tworzysz własnego motywu, wtyczki lub witryny internetowej, błędy te powinny zostać ukryte. Ponieważ jeśli pojawiają się one na front-endzie twojej witryny internetowej dla wszystkich odwiedzających, wygląda to wyjątkowo nieprofesjonalnie.

WordPress warning errors on homepage

Jeśli zobaczysz powyższy błąd na swojej witrynie WordPress, możesz poinformować o tym odpowiedniego twórcę motywu lub wtyczki. Mogą oni wydać poprawkę, która sprawi, że błąd zniknie. W międzyczasie możesz również wyłączyć te błędy.

Przyjrzyjmy się, jak łatwo wyłączyć błędy, powiadomienia i ostrzeżenia PHP w WordPress.

Wyłączanie błędów PHP w WordPress

W tym celu należy edytować plik wp-config.php.

W twoim pliku wp-config.php poszukaj następującego wiersza:

define('WP_DEBUG', true);

Możliwe jest również, że ta linia jest już ustawiona na false. W takim przypadku zobaczysz następujący kod:

define('WP_DEBUG', false);

W obu przypadkach należy zastąpić ten wiersz następującym kodem:

ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);

Nie zapomnij zapisać swoich zmian i przesłać pliku wp-config.php z powrotem na serwer.

Możesz teraz przejść na swoją witrynę internetową, aby potwierdzić, że błędy PHP, powiadomienia i ostrzeżenia zniknęły z twojej witryny.

Włączanie błędów PHP w WordPress

Jeśli pracujesz nad witryną internetową na serwerze lokalnym lub w obszarze przejściowym, możesz chcieć włączyć raportowanie błędów. W takim przypadku musisz edytować twój plik wp-config.php i zastąpić dodany wcześniej kod następującym kodem:

define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', true);

Ten kod pozwoli WordPressowi na ponowne rozpoczęcie wyświetlania błędów PHP, ostrzeżeń i powiadomień.

Mamy nadzieję, że ten artykuł pomógł ci dowiedzieć się, jak wyłączyć błędy PHP w WordPress. Możesz również zapoznać się z naszą listą najczęstszych błędów WordPress a i sposobami ich poprawki lub z naszym wyborem najlepszych programów do projektowania stron internetowych.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

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

41 komentarzyZostaw odpowiedź

  1. Syed Balkhi says

    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. A Owadud Bhuiyan says

    If I keep the debug true, but false the debug display. Will the error show on website?

    define(’WP_DEBUG’, true);
    define(’WP_DEBUG_DISPLAY’, false);

    • WPBeginner Support says

      The debug display being false would mean that the errors would not be visible on the front-end of your site.

      Administrator

  3. Janet says

    Thank you so much! This fixed my problem in 30 seconds that I have been waiting for my hosting to fix for over 12 hours.

    • WPBeginner Support says

      Glad our guide could help. As a reminder, this hides the error from your site but you would want to try to resolve the root cause of the error you were seeing.

      Administrator

  4. Karan says

    I have already done false in all . But in healthsite status always show WP debugging mode is enabled. please suggest me something

    • WPBeginner Support says

      You likely have it set to true in another section of the code, you likely want to reach out to your hosting provider for them to take a look and assist you.

      Administrator

    • WPBeginner Support says

      You would want to ensure wp_debug isn’t already added in your file somewhere else.

      Administrator

    • WPBeginner Support says

      You may want to check with your hosting provider to see if they have a log set up from their end

      Administrator

  5. Rebecca P says

    I’ve been advised to turn these notices off and was directed to this article to help me with that. However, I do not have the 'wp_debug’ line in my config file. Do I just add it in? And if so whereabouts in the file?
    Thanks!

    • WPBeginner Support says

      You may want to ensure you did not miss it in your current file but, you would place the code at the bottom of the file :)

      Administrator

  6. Gary Guss says

    Clueless newbie! I’ve changed the wp-config.php file and saved it .. Do I have to upload this file to the server to get it to work? How do I do that Using Cpanel File manager.. Not seeing any debug suppression so I guess its somehow not picking up the edited file.. Halp Halp!

    Thanks,

    GG

    • WPBeginner Support says

      If you’re using the file manager your host offers, and directly edited and saved through that without downloading the file then the changes should be active on your site and you would want to check with your host for why the changes may not be getting applied to the file.

      Administrator

  7. genfoch01 says

    ok so i know this is old, but i’m stumped. i am still getting php errors.

    Fatal error: Uncaught Error: Call to undefined function get_header() in /path/to/wordpress/wp-content/themes/mytheme/index.php:5 Stack trace: #0 {main} thrown in /path/to/wordpress/wp-content/themes/mytheme/index.php on line 5

    note that this issue was caught by a pen test and i was asked to suppress the error to avoid full paths being reveled. Any ideas would be helpful

    • WPBeginner Support says

      That is a fatal error for why it is still being displayed, you would want to either change themes or let your theme’s support know about the error to let you know how to fix it.

      Administrator

  8. Mzu says

    I need a solution on wordpress customizer that is not uploading l am stuck for weeks can’t customise any theme

  9. Abdulrahman says

    I faced the same problem after upating woocommerce plugin and the I used your method

    all erroers disappeared, however, I cannot log into the dashboard where it wp-admin shows a blank page

    is there any solution for that

    Thank you

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