2026年11月13日
2026年11月13日
WordPress Emoji Disappear or Won’t Save: Convert Tables to utf8mb4
This article is a localized edition of the Japanese original. Read the Japanese original
Most emoji problems in WordPress (with characters like 😀) come from the character set of your database tables. In UTF-8 an emoji takes 4 bytes, but MySQL/MariaDB's old utf8 character set (properly called utf8mb3) can only store characters of up to 3 bytes. The character set that can store 4-byte characters is utf8mb4.
Since version 4.2, WordPress creates its tables as utf8mb4 on a new install. Sites that are older than that, or that were moved from another server, may still have utf8mb3 tables. This article explains how to tell the symptoms apart, how to check the character set, and how to convert to utf8mb4.
Identify the cause from the symptom
These are the results of testing with WordPress 7.1.4 (the latest version as of October 2026) and MariaDB 11, with the tables set to utf8mb3.
| Symptom | Cause and what WordPress does |
|---|---|
Emoji in post content or titles are stored in the database as strings like 😀 |
The posts table is utf8mb3. WordPress converts emoji to HTML character references before saving (they still display) |
| Only the emoji in comments disappear | The comments table is utf8mb3. After the save fails, WordPress strips the emoji and saves again |
| Custom fields, plugin settings, tag names and the like don't save when they contain emoji | That table is utf8mb3. WordPress aborts the save and records the database error Processing the value for the following field failed |
Emoji are replaced with images (img.emoji) |
This is WordPress's emoji script at work, not an error (see below) |
Only for post content, titles and excerpts does WordPress check the table's character set and, if it is utf8mb3, convert emoji to character references before saving. That's why the problem is easy to miss in posts and often first noticed in comments or post meta.
Note that "Fatal error: Allowed memory size of ... bytes exhausted" is a PHP out-of-memory error and is not caused by emoji. For fixing memory errors, see Fixing "Allowed memory size exhausted" in WordPress: WP_MEMORY_LIMIT vs. WP_MAX_MEMORY_LIMIT vs. memory_limit.
Check the tables’ character set
If you can use WP-CLI, run the following in your WordPress directory. Only tables that are not utf8mb4 are listed.
wp db query "SELECT TABLE_NAME, TABLE_COLLATION FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_COLLATION NOT LIKE 'utf8mb4%';"
In phpMyAdmin, select the database, open the "SQL" tab, replace DATABASE() with the actual database name, and run the same SQL.
- Nothing is listed: all tables are
utf8mb4. Look for another cause of the emoji problem (such as plugin processing) - Tables with
utf8_...orutf8mb3_...are listed: convert them toutf8mb4with the steps below - Tables with
latin1_...or another non-UTF-8 character set are listed: don't convert them with the steps in this article. Their contents can become garbled (Fixing garbled characters in the WordPress database)
You can check the character set WordPress uses when it connects to the database with this command:
wp eval 'global $wpdb; echo $wpdb->charset, " ", $wpdb->collate, PHP_EOL;'
If it prints utf8mb4, the connection is fine. Even if DB_CHARSET in wp-config.php is 'utf8', WordPress switches to utf8mb4 when connecting, as long as the database supports it. If you're writing it fresh, use define( 'DB_CHARSET', 'utf8mb4' ); and leave DB_COLLATE empty ('').
Convert the tables to utf8mb4
This changes the table structure, so back up the database first. Large tables take time to convert, and writes are held up meanwhile, so do it at a quiet time.
# 1. Back up
wp db export before-utf8mb4.sql
# 2. Convert every table with the WordPress prefix (wp_ etc.) to utf8mb4
for t in $(wp db tables --all-tables-with-prefix --format=csv | tr ',' ' '); do
wp db query "ALTER TABLE \`$t\` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci;"
done
# 3. Verify (done if nothing is listed)
wp db query "SELECT TABLE_NAME, TABLE_COLLATION FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_COLLATION NOT LIKE 'utf8mb4%';"
utf8mb4_unicode_520_ciis the collation WordPress picks when it is available. You can also match the collation shown by thewp evalcommand in the previous stepwp db tables --all-tables-with-prefixcovers every table with a matching prefix, including tables created by plugins- On older databases such as MySQL 5.6, a plugin's table may fail to convert with a "Specified key was too long" error. WordPress core tables are designed to fit this limit, so ask the plugin's author about any table that errors out
After converting, enter emoji in a comment or custom field, save, and confirm they stay. Emoji that were already stripped from comments before the conversion won't come back.
For moving to another server, or for changing the default character set of the whole database, see How to change the MySQL charset and collation.
Emoji turning into images is not an error
WordPress outputs a script in the <head> of every page that checks whether the visitor's browser can display emoji. If the browser can't display some emoji, it loads emoji images from WordPress.org's server (s.w.org) and replaces them with img.emoji. This is not a bug; it's how emoji are shown even in older browsers.
To turn this off — for example to cut external requests or lighten the page — add the following to your theme's functions.php (a child theme is recommended) or your own plugin. The code was checked against the hooks in WordPress 7.1.
<?php
add_action( 'init', function () {
// Emoji detection script (front end, admin and embeds)
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'embed_head', 'print_emoji_detection_script' );
// Styles for emoji images (since WordPress 6.4, wp_enqueue_emoji_styles checks for these hooks)
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
// Converting emoji to images in feeds and email
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
} );
After you turn it off, emoji are displayed with the fonts of the browser or operating system. Turning it off has no effect on saving to the database (the problem in the previous sections). For details, see How to disable the WordPress emoji script.
Summary
- Emoji disappear or won't save because the table character set isn't
utf8mb4.utf8(utf8mb3) can't store emoji - WordPress converts emoji in post content to character references before saving, but strips them from comments and aborts saves of post meta and settings
- Check the character set in
information_schema.TABLES, take a backup, then convert withALTER TABLE ... CONVERT TO CHARACTER SET utf8mb4. Don't convertlatin1tables this way - Emoji turning into images is WordPress's emoji script; if you don't need it, turn it off with
remove_action
Related articles:
- How to unify the WordPress database character set to UTF-8
- Fixing garbled characters in the WordPress database
- How to disable the WordPress emoji script
Questions about WordPress? The publisher of this site is based in Japan and replies in Japanese. Contact (Japanese)