Aleš Sýkora / November 28, 2023 / 1 comments

Emoji deleted from ACF field after saving

Post summary: So you have a ACF text field and you are trying to insert emoji to it. For example as a category icon. You add the field, add the emoji, use the PHP code to display the field. And emoji is missing. After that you found that every time you save the page, emoji dissapear from…

So you have a ACF text field and you are trying to insert emoji to it. For example as a category icon. You add the field, add the emoji, use the PHP code to display the field. And emoji is missing.

After that you found that every time you save the page, emoji dissapear from the field. Why? Because you have wrong database character set. Go to your wp-config.php file on ftp and search for:

/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );

If there is DB_CHARSET set to utf8, you found the problem. You need to set your database to utf8mb4_unicode_ci.

Hot to do that?

I am not responsible for your crashed sites etc.. Please do a backup before!!

Change this line in wp-config.php to

/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8mb4' );

Then go to your WordPress database via phpMyAdmin and select your database. You can see your collation in column.

Collation column

Go to the edits and set Collations to utf8mb4_unicode_ci and change in all tables and table columns. Click on apply-

You are done :-) your emoji will stay in fields now.

Fuel my passion for writing with a beer🍺

Your support not only makes me drunk but also greatly motivates me to continue creating content that helps. Cheers to more discoveries and shared success. 🍻

1 comments

Share Your Thoughts