Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Run this when you see weird crap in your posts/comments after moving your WordPress install.
update wp_posts set post_content = replace(post_content,'’','\'');
update wp_posts set post_title = replace(post_title,'’','\'');
update wp_comments set comment_content = replace(comment_content,'’','\'');
update wp_postmeta set meta_value = replace(meta_value,'’','\'');
update wp_posts set post_excerpt = replace(post_excerpt,'’','\'');
update wp_posts set post_content = replace(post_content,'…','...');
update wp_posts set post_title = replace(post_title,'…','...');
update wp_comments set comment_content = replace(comment_content,'…','...');
update wp_postmeta set meta_value = replace(meta_value,'…','...');
update wp_posts set post_excerpt = replace(post_excerpt,'…','...');
update wp_posts set post_content = replace(post_content,'–','-');
update wp_posts set post_title = replace(post_title,'–','-');
update wp_comments set comment_content = replace(comment_content,'–','-');
update wp_postmeta set meta_value = replace(meta_value,'–','-');
update wp_posts set post_excerpt = replace(post_excerpt,'–','-');
update wp_posts set post_content = replace(post_content,'“','"');
update wp_posts set post_title = replace(post_title,'“','"');
update wp_comments set comment_content = replace(comment_content,'“','"');
update wp_postmeta set meta_value = replace(meta_value,'“','"');
update wp_posts set post_excerpt = replace(post_excerpt,'“','"');
update wp_posts set post_content = replace(post_content,'‘','\'');
update wp_posts set post_title = replace(post_title,'‘','\'');
update wp_comments set comment_content = replace(comment_content,'‘','\'');
update wp_postmeta set meta_value = replace(meta_value,'‘','\'');
update wp_posts set post_excerpt = replace(post_excerpt,'‘','\'');
update wp_posts set post_content = replace(post_content,'•','-');
update wp_posts set post_title = replace(post_title,'•','-');
update wp_comments set comment_content = replace(comment_content,'•','-');
update wp_postmeta set meta_value = replace(meta_value,'•','-');
update wp_posts set post_excerpt = replace(post_excerpt,'•','-');
update wp_posts set post_content = replace(post_content,'‡','c');
update wp_posts set post_title = replace(post_title,'‡','c');
update wp_comments set comment_content = replace(comment_content,'‡','c');
update wp_postmeta set meta_value = replace(meta_value,'‡','c');
update wp_posts set post_excerpt = replace(post_excerpt,'‡','c');
update wp_posts set post_content = replace(post_content,'â€','"');
update wp_posts set post_title = replace(post_title,'â€','"');
update wp_comments set comment_content = replace(comment_content,'â€','"');
update wp_postmeta set meta_value = replace(meta_value,'â€','"');
update wp_posts set post_excerpt = replace(post_excerpt,'â€','"');
update wp_posts set post_content = replace(post_content,'Â','');
update wp_posts set post_title = replace(post_title,'Â','');
update wp_comments set comment_content = replace(comment_content,'Â','');
update wp_postmeta set meta_value = replace(meta_value,'Â','');
update wp_posts set post_excerpt = replace(post_excerpt,'Â','');
@boogah

This comment has been minimized.

Copy link
Owner Author

commented Nov 7, 2012

Adding Jeremy Pry's edits for readability and the 'Â' character.

@mistertwo

This comment has been minimized.

Copy link

commented Dec 27, 2013

Here's a few queries to cover post excerpts:

update wp_posts set post_excerpt = replace(post_excerpt,'’','\'');

update wp_posts set post_excerpt = replace(post_excerpt,'…','...');

update wp_posts set post_excerpt = replace(post_excerpt,'–','-');

update wp_posts set post_excerpt = replace(post_excerpt,'“','"');

update wp_posts set post_excerpt = replace(post_excerpt,'‘','\'');

update wp_posts set post_excerpt = replace(post_excerpt,'•','-');

update wp_posts set post_excerpt = replace(post_excerpt,'‡','c');

update wp_posts set post_excerpt = replace(post_excerpt,'�','"');

update wp_posts set post_excerpt = replace(post_excerpt,'Â','');
@boogah

This comment has been minimized.

Copy link
Owner Author

commented Aug 29, 2014

Added mister two's post excerpt fixes. 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.