In the latest WordPress version after (5.0) most of the time we didn’t find actual WordPress error messages many times we have seen simple text messages on your site. “The site is experiencing technical difficulties. Please check your site admin email inbox for instructions.” If you want to get actual error messages we need first to enable debug mode in the wp-config.php file.
If your site is live we can query parameters to open the debugging like this:
if(isset($_GET['debug'])) { define ('WP_DEBUG', true); } else { define ('WP_DEBUG', false); }
After this we need to add a filter hook in your theme function file hook name is “wp_php_error_message” for more information you see here https://developer.wordpress.org/reference/classes/wp_fatal_error_handler/display_default_error_template/, https://developer.wordpress.org/reference/hooks/wp_php_error_message/
This hook contains 2 parameters
#Parameters
1.) $message
(string) HTML error message to display.
2.) $error
(array) Error information retrieved from error_get_last().
So we can write add hook in your function file like this:
add_filter( 'wp_php_error_message', 'filter_function_for_debug', 3, 2 ); function filter_function_for_debug( $message, $error ){ if(isset($_GET['debug'])) { //print_r($error);die; } return $message; }