admin管理员组

文章数量:1125368

Just updated my local and live installs for a side project to 4.2 in order to take advantage of the newly added Emoji features. Emoji are working just fine on my local machine, but they seem to not be working as comments on the live version.

Local

  • emoji in post title - working
  • emoji in post content - working
  • emoji in comments - working

Live

  • emoji in post title - working
  • emoji in post content - working
  • emoji in comments - not working

Troubleshooting

  • Theme - Tried activating Twenty Fifteen; didn't work.
  • Plugins - Tried deactivating all plugins; didn't work.
  • Theme + Plugins - Tried activating Twenty Fifteen and deactivating all plugins; didn't work.
  • Normal comments - Regular characters save and display as comments just fine.
  • Emoji - they display in the 'comment field' when adding a comment, but once submitted, the seem to be stripped out. In wp-admin an emoji comment just seems to be blank with no text at all.

I have tried all of the basic troubleshooting I can think of, are there any other things I am not thinking of?

Just updated my local and live installs for a side project to 4.2 in order to take advantage of the newly added Emoji features. Emoji are working just fine on my local machine, but they seem to not be working as comments on the live version.

Local

  • emoji in post title - working
  • emoji in post content - working
  • emoji in comments - working

Live

  • emoji in post title - working
  • emoji in post content - working
  • emoji in comments - not working

Troubleshooting

  • Theme - Tried activating Twenty Fifteen; didn't work.
  • Plugins - Tried deactivating all plugins; didn't work.
  • Theme + Plugins - Tried activating Twenty Fifteen and deactivating all plugins; didn't work.
  • Normal comments - Regular characters save and display as comments just fine.
  • Emoji - they display in the 'comment field' when adding a comment, but once submitted, the seem to be stripped out. In wp-admin an emoji comment just seems to be blank with no text at all.

I have tried all of the basic troubleshooting I can think of, are there any other things I am not thinking of?

Share Improve this question asked Apr 24, 2015 at 17:53 Stephen S.Stephen S. 1,0292 gold badges13 silver badges21 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 1

I have just solved this!

The emoji needs to be converted to UTF8 encoded string while storing in MySQL database and of course your database column collation must be utf8mb4: <?php utf8_encode($comment); ?> Then while displaying do the reverse: <?php utf8_decode($comment); ?> I'm sorry I don't have code for WordPress as I use it only as a CMS to store the data and use another PHP MVC framework to fetch it for API.

Hope this helps.

It seems you need to change the Collation for the wp_comments and wp_commentmeta tables on your Live server to utf8mb4_unicode_ci.

本文标签: Troubleshooting Emoji in Comments