Weird characters appearing on WordPress posts

  |   By  |  0 Comments

If weird characters suddenly appear on your blog posts and pages. Don’t panic.

You may see Don’t instead of Don’t for instance. This can happen when a database is restored or updated because the character set has been changed

Here are some common examples…

“ = left quote = “
” = right quote = ”

‘ = left single quote = ‘
’ = right single quote = ’

— = en dash = –
– = em dash = —

• = hyphen = –
… = ellipsis = …

If you know how to use PHPMyAdmin, you can use these simple queries to sort it out(assuming your database prefix is wp_)

UPDATE wp_posts SET post_content = REPLACE(post_content, '“', '"');
UPDATE wp_posts SET post_content = REPLACE(post_content, '”', '"');
UPDATE wp_posts SET post_content = REPLACE(post_content, '’', ''');
UPDATE wp_posts SET post_content = REPLACE(post_content, '‘', ''');
UPDATE wp_posts SET post_content = REPLACE(post_content, 'â€"', '–');
UPDATE wp_posts SET post_content = REPLACE(post_content, 'â€"', '—');
UPDATE wp_posts SET post_content = REPLACE(post_content, '•', '-');
UPDATE wp_posts SET post_content = REPLACE(post_content, '…', '…');
UPDATE wp_posts SET post_content = REPLACE(post_content, 'Â', ' ');
UPDATE wp_comments SET comment_content = REPLACE(comment_content, '“', '"');
UPDATE wp_comments SET comment_content = REPLACE(comment_content, '”', '"');
UPDATE wp_comments SET comment_content = REPLACE(comment_content, '’', ''');
UPDATE wp_comments SET comment_content = REPLACE(comment_content, '‘', ''');
UPDATE wp_comments SET comment_content = REPLACE(comment_content, 'â€"', '–');
UPDATE wp_comments SET comment_content = REPLACE(comment_content, 'â€"', '—');
UPDATE wp_comments SET comment_content = REPLACE(comment_content, '•', '-');
UPDATE wp_comments SET comment_content = REPLACE(comment_content, '…', '…');
UPDATE wp_comments SET comment_content = REPLACE(comment_content, 'Â', ' ');

If you have no idea how to do that, here’s a simple £2.50 plugin for you to do the job. You are advised to backup your database first just in case.

Once you have paid above you will get a link to download weird-character-fixer.zip. Then goto your website dashboard and click on Plugins, then Add New, then Upload and finally Activate. A menu item “Weird Chara Fixer” will appear. Best practice is to backup your WordPress database using the plugin link for safety and then click Fix Now. Hope it helps you – I just fixed a site for a client with 55,000 posts and 16,000 had been corrupted!