Skip to content

Instantly share code, notes, and snippets.

@johndiego
Forked from JPry/wp-fix.sql
Created October 11, 2022 17:59
Show Gist options
  • Save johndiego/a6e5f077e863752c63aed5ae6f07fb48 to your computer and use it in GitHub Desktop.
Save johndiego/a6e5f077e863752c63aed5ae6f07fb48 to your computer and use it in GitHub Desktop.
Remove funky characters in WordPress database
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_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_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_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_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_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_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_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_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,'Â','');
@johndiego
Copy link
Author

UPDATE wp_posts SET post_content= replace(post_content,'0000-000-0000','0800-0000-0000');
UPDATE wp_posts SET post_title= replace(post_title,'0000-0000-0000','0000-0000-0000');
UPDATE wp_postmeta SET meta_value= replace(meta_value,'0000-0000-0000','0000-0000-0000');

UPDATE wp_posts SET post_content= replace(post_content,'0000 0000 0000','0000-0000-0000');
UPDATE wp_posts SET post_title= replace(post_title,'0000 0000 0000','0000-0000-0000');
UPDATE wp_postmeta SET meta_value= replace(meta_value,'0000 0000 0000','0000-0000-0000');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment