I am having some issues with character encoding on imported posts from an old Wordpress install. I am getting black diamonds with question marks on some of the posts I have imported to a new install. The issue only seems to exist in post excerpts, when I click to view the full post, the missing characters are not there and when I click "edit post" they are not visible in the backend either. I have found several topics regarding this issue, but none of the solutions have worked for me so far.

The new install is using define('DB_CHARSET', 'utf8mb4'); in wp-config.php whereas the old site(where I imported the posts from) is using define('DB_CHARSET', 'utf8');

I'm not sure what character is even having trouble being encoded. I think it's just an nbsp; but there are other places with nbsp; that are not showing as question marks, so I'm stumped. Any quick remedy for this issue?

Things I have tried:

  • Commenting out define('DB_CHARSET', 'utf8mb4'); and define('DB_COLLATE', ''); (This created even more question marks)
  • Adding <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> to header.php
  • Setting back to define('DB_CHARSET', 'utf8'); in the wp-config.php
  • Have you tried setting the define back to UTF-8, along with the database?
    – Mat
    May 7, 2018 at 20:06
  • I tried setting the define back to UTF-8, but the problem persisted. I'm not sure how to safely make the change to the database, since the database seems to be using a mix of encodings(for example, I have tables from a plugin using utf8_general_ci, whereas the default Wordpress tables are using utf8mb4_unicode_520_ci).
    – user13286
    May 7, 2018 at 20:09
  • 2
    Take a backup of your database then look at dba.stackexchange.com/questions/94789/…
    – Mat
    May 7, 2018 at 20:46
  • Have you checked the database is actually using that encoding? define( 'DB_CHARSET', 'emoji' ); won't change your tables retroactively. Or that the version of MySQL you're using actually supports utf8mb4
    – Tom J Nowell
    May 7, 2018 at 21:41


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.