Are you looking for a way to show PHP errors for your WordPress theme to the website admin only? While there’s probably a plugin for this, we have created a quick code snippet that you can use to show PHP errors in WordPress.
The code will check if the user is an admin for the WordPress site before showing the PHP errors.
Instructions:
All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:
if ( current_user_can( 'administrator' ) ) { define('WP_DEBUG_DISPLAY', true); @ini_set('display_errors', 1); }
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.
If you liked this code snippet, please consider checking out our other articles on the site like: 43 best photography themes for WordPress and how to set up Google Analytics eCommerce tracking for WooCommerce.
Comments Leave a Reply