Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Clean up malformed characters in WordPress database
## Run this in phpMyadmin
##
## Cleans up Posts table
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, 'Â', '');
##
##
## Cleans up Comments
##
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, 'Â', '');
##
##
## Cleans up User Meta (descriptions)
##
UPDATE wp_usermeta SET meta_value = REPLACE(meta_value, '“', '');
UPDATE wp_usermeta SET meta_value = REPLACE(meta_value, '”', '');
UPDATE wp_usermeta SET meta_value = REPLACE(meta_value, '’', '');
UPDATE wp_usermeta SET meta_value = REPLACE(meta_value, '‘', '');
UPDATE wp_usermeta SET meta_value = REPLACE(meta_value, '—', '');
UPDATE wp_usermeta SET meta_value = REPLACE(meta_value, '–', '');
UPDATE wp_usermeta SET meta_value = REPLACE(meta_value, '•', '-');
UPDATE wp_usermeta SET meta_value = REPLACE(meta_value, '…', '');
UPDATE wp_usermeta SET meta_value = REPLACE(meta_value, 'Â', '');
@dhornbein

This comment has been minimized.

Copy link

dhornbein commented Jul 15, 2013

You saved me a lot of work, thank you.

@mmizwicki

This comment has been minimized.

Copy link

mmizwicki commented Jan 8, 2014

This is gold! Thank you.

@amolbnaik

This comment has been minimized.

Copy link

amolbnaik commented May 8, 2014

if you had not saved me... !@#$. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.