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. 😎

2 responses on “WordPress emojis not working with PHP 8 😲

  1. Darren

    Do you know how to remove those extensions from WAMP? I’ve gone through the same issue, only that when I migrate my database from the remote server to the localhost, some of the emojis are wiped out and leave “????” in place of where the emoji would be.

    I can only assume the same issue with extensions is present on WAMP 3.3.2, but it’s not clear how to remove these.

    1. Anthony Hortin Post author

      Hi Darren,
      WAMP works a little different to your typical hosting that operates on cPanel. Since I don’t use WAMP I can’t point you directly to any particular setting to adjust, but I would suggest having a look through the menus and seeing if there’s any option to modify the templates that get loaded when it loads PHP and mySQL. You may find something in there that will help. Unfortunately, that’s about the only suggestion I can offer, sorry. I hope it helps.