• 27/12/2020 • 3 phút đọc • 10 lượt xem

How to Disable WordPress PHP Error Messages

Việt Lâm Coder
Việt Lâm Coder
Senior Fullstack & System Architect • Hotline: 0944.71.4545

WordPress has a built-in method of debugging that works great for developers. It offers a warning message detailing what file is at fault and what line to look at. However, this often looks terrible from a visitor perspective. It’s a WordPress error message that can easily dissuade people from coming back.

In this tutorial, I’m going to show you how to disable the warning message in WordPress when it comes to debugging. It’s a simple bit of code you can copy and paste into your website.

What Causes these PHP Error Messages?


A lot of the time, line warnings in PHP files happen because of outdated plugins or themes. This is because core files will often change with WordPress updates, which makes some parts of code obsolete.

Themes and plugins can also throw PHP warning messages when used with something that is incompatible. It’s possible for two current plugins which work well by themselves to have issues when paired together. This is because every developer is different, and not everyone uses the same syntax when developing website files.

Luckily, these warnings don’t necessarily mean the site is broken. They just look ugly to an unsuspecting visitor. Sometimes the developer will create an update to fix the warning, but it’s not always quick.

PHP warnings in WordPress look something like this:

“/wp-content/plugins/siteplugin.php on line 30”

This doesn’t mean the plugin is bad. It just means part of the file is incompatible with WordPress, the theme or another plugin that is in use.

Unless you plan on fixing the coding yourself, it’s probably better to simply disable the warning messages altogether. If the tool isn’t completely broken or unusable, then the warning may not completely apply to you.

Hiding the WordPress PHP Warnings


This next part involves editing the wp-config.php file of WordPress.

I strongly suggest you create a backup of your site before making any coding changes. This will protect you in the event something goes wrong by giving you a quick method to restore the site.

You have several methods available for accessing the wp-config.php file of WordPress. A lot of people like using FTP applications like FileZilla to access website resources.

For this tutorial, I’m simply going to use the File Manager in cPanel.

Use File Manager

Access your website by clicking the “public_html” folder in the directory.

PUBLIC HTML

Select the wp-config.php file and click, “Edit.” It’s located in the top tool bar of File Manager.

Edit

Click the “Edit” button on the new window. This is just a message allowing you to change the character encoding of the editor. You will not need to make any changes to this section.

Click Edit

Scroll down and find the line that has this code:


define('WP_DEBUG', false);

You may see “true” instead of false. Either way, you’re looking for the “WP_DEBUG” portion of the wp-config.php file.

Replace the line with the following code:


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

Click the “Save Changes” button in the top right.

Once the file is saved, this will disable the PHP warnings in WordPress.

Enabling Warning Messages


If you want to re-enable the PHP warning messages, edit these lines by pasting this instead:

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

Customizing Your Website

Hiding WordPress warnings is only one piece of a massive customization puzzle within WordPress. With a simple copy-and-paste code, you can make a variety of changes without having previous experience in website development. Just make sure you’re copying good snippets of code. Something that is obsolete or improperly created could easily crash a website.

How often do you edit coding in your WordPress site? Where is your favorite place to go for code snippets?

Việt Lâm Coder

Việt Lâm Coder

Tác giả bài viết và chuyên gia quản trị website. Nếu bạn gặp khó khăn trong quá trình thực hiện hoặc có nhu cầu thiết kế website, lập trình web app Laravel, hãy liên hệ ngay với tôi qua Hotline / Zalo: 0944.71.4545.

☕ Mời Tác Giả Ly Cà Phê Ấm Lòng

Nếu bài viết này giúp ích cho công việc của bạn, hãy tiếp thêm động lực cho tác giả duy trì kho tri thức bằng một ly cà phê ấm lòng nhé!

Mã QR ủng hộ tác giả
Ngân hàng TMCP Quân Đội (MB Bank)TONG VIET LAM

Có Thể Bạn Quan Tâm

Cách Mở Tab Ẩn Danh Trên Safari MacBook Đơn Giản

Cách mở tab ẩn danh trên Safari MacBook sẽ giúp cho người dùng có thể bảo vệ quyền riêng tư và duyệt web một cách an toà...

Hướng dẫn 5 cách tắt update Windows 11 vĩnh viễn chi tiết nhất

Mặc định Windows 11 sẽ được tự động cập nhật trong nền. Tuy nhiên nếu vì lý do nào đó mà bạn không muốn nhận các bản...

Hướng dẫn trỏ file hosts cho domain trên hệ điều hành Windows

– Làm cách nào để 1 website có thể hoạt động trên Share hosting, VPS, Server mà không cần cấu hình các record DNS cho do...

Kích hoạt Cloudflare Turnstile trong Contact Form 7 chống spam

Cloudflare Turnstile là giải pháp xác thực không dùng CAPTCHA giúp bảo vệ website WordPress khỏi spam một cách nhẹ nhàng...

Cách Sử Dụng DeepSeek R1 Miễn Phí Trong Visual Studio Code Với Cline?

Hãy đối mặt với thực tế: Các trợ lý lập trình AI như GitHub Copilot thì tuyệt vời, nhưng chi phí đăng ký của chúng có th...

Gmail API – Tất cả những gì bạn cần biết - 2025

Nếu bạn đang tìm cách tích hợp Gmail vào các ứng dụng của riêng mình thì Gmail API chính là thứ bạn cần! Gmail là một lự...

Hướng dẫn tạo màn hình desktop ảo bằng Task View trên Surface Windows 11

Việt Lâm Coder sẽ hướng dẫn tạo lập nhiều màn hình desktop ảo bằng Task View trên Surface Windows 11 để sắp xếp các tác...

How to Transfer PuTTY Sessions To Another Windows Machine

his is an user contributed article. PuTTY is a terminal emulator application which can act as a client for the SSH, T...

Hướng dẫn cách kiểm tra cổng đang mở (Check open port) trên linux

Với nhiều năm kinh nghiệm hỗ trợ Khách hàng của Tenten, chúng tôi nhận thấy việc thường xuyên theo dõi kiểm tra hoạt độn...

Kiểm tra tất cả các port mà Cyber Panel đang cần có được mở hay không ?

Để kiểm tra tất cả các port cùng một lúc, bạn có thể sử dụng lệnh: netstat -tulpn | grep -E ':(8090|80|443|21|40110|401...

Hướng dẫn cài đặt KeyHelp Panel

Tóm tắt về KeyHelp Bạn đã có phần cứng tốt nhất cho các dự án Internet của mình nhưng việc quản lý phức tạp, hiệu suất...

Tổng hợp danh sách Control Panel VPS free tốt nhất hiện nay

Control Panel VPS free cung cấp một lựa chọn tuyệt vời cho những người dùng muốn quản lý VPS một cách dễ dàng và hiệ...