code ); nocache_headers(); global $wp_version; if ( version_compare( $wp_version, '5.1', '<' ) ) { header( 'X-Redirect-Agent: redirection' ); } else { header( 'X-Redirect-By: redirection' ); } } public function pre_handle_404() { global $wp_query; // Page comments plugin interferes with this $wp_query->posts = []; return false; } public function template_include() { $template = get_404_template(); if ( ! is_string( $template ) || $template === '' ) { $template = get_index_template(); } return $template; } public function name() { return __( 'Error (404)', 'redirection' ); } }