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

WordPressでPHPエラーをオフにする方法

編集メモ: WPBeginner のパートナーリンクから手数料を得ています。手数料は編集者の意見や評価に影響を与えません。編集プロセスについて詳しく知る。

最近、読者の一人から、WordPressでPHPエラーをオフにする方法は?

PHPの警告や通知は、開発者がコードの問題をデバッグするのに役立ちます。しかし、サイト訪問者すべてから見えるようにすると、非常にプロらしくなくなります。

この投稿では、WordPressのPHPエラーを簡単にオフにする方法を紹介します。

How to turn off PHP errors in WordPress

WordPressでPHPエラーをオフにする理由とタイミングとは?

WordPressサイトで見られるPHPエラーは通常、警告や通知です。これらは、内部サーバーエラー構文エラー致命的なエラーのようなものではありません。

通知と警告は、WordPressがサイトを読み込むのを止めない種類のエラーです。詳しくは、WordPressが実際に裏でどのように動作しているかをご覧ください。

PHP errors in WordPress admin area

これらのエラーの目的は、開発者がコードの問題をデバッグするのを助けることです。プラグインやテーマの開発者は、互換性やベストプラクティスをチェックするためにこの情報が必要です。

しかし、カスタマイザーやプラグイン、サイトを開発していないのであれば、これらのエラーは非表示にすべきです。なぜなら、サイトのフロントエンドですべての訪問者に表示されると、非常にプロらしくないように見えるからです。

WordPress warning errors on homepage

WordPressサイトで上記のようなエラーが表示される場合は、テーマやプラグインの開発者に連絡してください。エラーが消えるような修正プログラムがリリースされるかもしれない。一方、これらのエラーをオフにすることもできる。

WordPressのPHPエラー、通知、警告を簡単にオフにする方法を見てみましょう。

WordPressのPHPエラーをオフにする

この部分については、wp-config.phpファイルを編集する必要があります。

wp-config.phpファイルの中で、以下の行を探してください:

define('WP_DEBUG', true);

この行がすでにfalseに設定されている可能性もある。その場合、次のようなコードが表示される:

define('WP_DEBUG', false);

どちらの場合も、この行を以下のコードに置き換える必要がある:

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

変更を保存し、wp-config.phpファイルをサーバーにアップロードすることを忘れないでください。

これで、PHPエラー、通知、警告がサイトから消えたことを確認できます。

WordPressでPHPエラーをオンにする

ローカルサーバーや ステージングエリアでサイトを作成している場合、エラーレポートを有効にしたい場合があります。その場合は、wp-config.phpファイルを編集し、先ほど追加したコードを以下のコードに置き換える必要があります:

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

このコードにより、WordPressはPHPエラー、警告、通知を再び表示するようになります。

この投稿が、WordPressのPHPエラーをオフにする方法を学ぶのにお役に立てば幸いです。WordPressの最も一般的なエラーとその修正方法のリストや、専門家が選ぶ最高のウェブデザインソフトウェアもご覧ください。

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.

情報開示 私たちのコンテンツは読者支援型です。これは、あなたが私たちのリンクの一部をクリックした場合、私たちはコミッションを得ることができることを意味します。 WPBeginnerの資金源 をご覧ください。3$編集プロセスをご覧ください。

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.

究極のWordPressツールキット

ツールキットへの無料アクセス - すべてのプロフェッショナルが持つべきWordPress関連製品とリソースのコレクション!

Reader Interactions

41件のコメント返信を残す

  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.

      管理者

  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.

      管理者

  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.

      管理者

    • WPBeginner Support says

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

      管理者

    • WPBeginner Support says

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

      管理者

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

      管理者

  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.

      管理者

  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.

      管理者

  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

返信を残す

コメントありがとうございます。すべてのコメントは私たちのコメントポリシーに従ってモデレートされ、あなたのメールアドレスが公開されることはありませんのでご留意ください。名前欄にキーワードを使用しないでください。個人的で有意義な会話をしましょう。