Do you have the latest version of WordPress installed? The latest version of WordPress should work with PHP 8.1 without any errors.
If you are using the latest version of WordPress, this problem may be a plugin or theme conflict. Please attempt to deactivate all plugins and switch to the default Twenty Twenty-Three theme. If the problem goes away, re-activate them one by one to identify the source of the problem.
If you can install plugins, install Health Check. On the troubleshooting tab, you can click the button to deactivate all plugins and change the theme for you while you’re still logged in without affecting normal visitors to your site.
Thanks everyone. Upgraded WordPress to the latest version, will see if the problem still exists.