Posted in WordPress by
Anthony Hortin

I had an issue with one of my own sites recently, where it wouldn’t let me save Emojis in the post content. The site itself is nothing out of the ordinary and is just using the Classic Editor. This particular site was also running PHP 8.1.

For an issue such as this, I checked that the wp-config file had define('DB_CHARSET', 'utf8mb4');. The database collation was also utf8mb4. As a simple test, I also tried editing some page content directly in the wp_posts table using phpMyAdmin. I was able to save the content with an emoji 🎉, but when I refreshed the content in the Post Editor it simply showed as a ?. Likewise, when trying to view the content in the browser ☹️. The exact same site was working fine in my local development environment, and I even tried disabling plugins to see if they were the cause, but the issue still remained. 🤬

It just so happened that I had another site on the same host, and after testing it, I found that emojis were working fine. This other site was running on PHP 7.4. As soon as I switched that site to PHP 8.1 though, emojis stopped working. 😥

Thankfully, after doing a little more investigation, I eventually found out what the issue was, thanks to this post on the WordPress support forums. In short, when switching to PHP 8.1, this particular host enabled the mysqli and mysqlnd extensions for database connectivity. Under PHP 7.4 though, it used mysqlnd and nd_mysqli. So… I simply disabled mysqli and enabled nd_mysqli instead and everything started working again. Yay! 🎉

Within cPanel, you can find the PHP extensions, and enable/disable them, within the PHP Selector module.

I hope this little tip helps you if you’re having issues with your emojis after switching to PHP 8.x. 😎

Leave a Reply

Your email address will not be published. Required fields are marked *