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 disattivare gli errori PHP in WordPress

Nota editoriale: guadagniamo una commissione dai link dei partner su WPBeginner. Le commissioni non influenzano le opinioni o le valutazioni dei nostri redattori. Per saperne di più su Processo editoriale.

Recentemente uno dei nostri lettori ci ha chiesto come disattivare gli errori PHP in WordPress.

Le avvertenze e gli avvisi di PHP aiutano gli sviluppatori a individuare i problemi del loro codice. Tuttavia, il fatto che siano visibili a tutti i visitatori del vostro sito web ha un aspetto estremamente poco professionale.

In questo articolo vi mostreremo come disattivare facilmente gli errori PHP in WordPress.

How to turn off PHP errors in WordPress

Perché e quando disattivare gli errori PHP in WordPress?

Gli errori PHP che potete vedere sul vostro sito WordPress sono solitamente avvisi e notifiche. Non si tratta di errori interni del server, di errori di sintassi o di errori fatali, che impediscono il caricamento del sito web.

Gli avvisi e le avvertenze sono errori che non impediscono a WordPress di caricare il vostro sito web. Per maggiori dettagli, consultate il funzionamento di WordPress dietro le quinte.

PHP errors in WordPress admin area

Lo scopo di questi errori è quello di aiutare gli sviluppatori a individuare i problemi con il loro codice. Gli sviluppatori di plugin e temi hanno bisogno di queste informazioni per verificare la compatibilità e le best practice.

Tuttavia, se non si sta sviluppando un tema, un plugin o un sito web personalizzato, questi errori devono essere nascosti. Perché se appaiono sul front-end del vostro sito web a tutti i visitatori, hanno un aspetto estremamente poco professionale.

WordPress warning errors on homepage

Se si riscontra un errore come quello sopra descritto sul proprio sito WordPress, si consiglia di informare lo sviluppatore del tema o del plugin. Potrebbero rilasciare una correzione per far scomparire l’errore. Nel frattempo, è anche possibile disattivare questi errori.

Vediamo come disattivare facilmente gli errori, gli avvisi e le avvertenze PHP in WordPress.

Disattivare gli errori PHP in WordPress

Per questa parte, è necessario modificare il file wp-config.php.

All’interno del file wp-config.php, cercate la seguente riga:

define('WP_DEBUG', true);

È anche possibile che questa riga sia già impostata su false. In tal caso, si vedrà il seguente codice:

define('WP_DEBUG', false);

In entrambi i casi, è necessario sostituire questa riga con il codice seguente:

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

Non dimenticate di salvare le modifiche e di caricare il file wp-config.php sul server.

Ora è possibile visitare il sito web per verificare che gli errori, gli avvisi e le avvertenze PHP siano scomparsi dal sito.

Attivare gli errori PHP in WordPress

Se si sta lavorando a un sito web su un server locale o su un’area di staging, si potrebbe voler attivare la segnalazione degli errori. In questo caso, è necessario modificare il file wp-config.php e sostituire il codice aggiunto in precedenza con il seguente:

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

Questo codice permetterà a WordPress di ricominciare a visualizzare gli errori, le avvertenze e gli avvisi di PHP.

Speriamo che questo articolo vi abbia aiutato a capire come disattivare gli errori PHP in WordPress. Potreste anche voler consultare il nostro elenco degli errori più comuni di WordPress e di come risolverli, oppure la nostra selezione di esperti dei migliori software di web design.

Se questo articolo vi è piaciuto, iscrivetevi al nostro canale YouTube per le esercitazioni video su WordPress. Potete trovarci anche su Twitter e Facebook.

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

41 commentiLascia una risposta

  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.

      Admin

  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.

      Admin

  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.

      Admin

    • WPBeginner Support says

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

      Admin

  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 :)

      Admin

  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.

      Admin

  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.

      Admin

  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

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.