How to hide PHP Warnings and Notices in WordPress?
You can hide PHP Warnings and Notices in wordpress by using the WP_DEBUG constant in wp-config.php file or you can use php ini_set('display_errors','Off');
and ini_set('error_reporting', E_ALL );
functions to hide the php warnings and notices from the front-end of your website.
The ini_set function in PHP allows you to change the configuration settings of your PHP installation at runtime. The ini_set('display_errors','Off')
, turns off the display of errors, while the ini_set('error_reporting', E_ALL )
function, sets the error reporting level to E_ALL, which reports all errors and warnings.
Hide PHP Warnings and Notices in wordpress using WP_DEBUG constant
WP_DEBUG constant is used to control the debugging mode in WordPress. By setting it to false in your wp-config.php file, you can turn off warnings and notices.
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
The first line, WP_DEBUG, sets the WordPress debugging mode to off, and the second line, WP_DEBUG_DISPLAY, turns off the display of errors. This way, the warnings and notices will not be shown on the front-end of your website, but they will still be logged in the error logs.
Hide PHP Warnings and Notices in wordpress using ini_set function in wp-config.php
If the above method does not work then you can replace define('WP_DEBUG', true); with the below code in wp-config.php file which exists at the root of wordpress project directory.
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_DISPLAY', false);
Enable debug logging in wordpress
wp-config.php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Wordpress
- Function to get the post id in while (have_posts()) : the_post();
- Create a accordion plugin in wordpress
- Create shortcode in wordpress functions php
- How to display author avatar in Wordpress 5
- Remove every class and ID from the wp_nav_menu
- Custom post type in wordpress
- Replace Live Site Url with Local Site URL in wordpress database
- How to use shop in product category and product permalink in woocommerce
- Add new class to body tag in wordpress
- Remove class from body tag in wordpress
- Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2348617 bytes) in /home/xxx/public_html/wp-includes/plugin.php on line xxx
- Show template file name in wordpress