Skip to content

Instantly share code, notes, and snippets.

@andcam
Created July 20, 2022 01:06
Show Gist options
  • Save andcam/d8e54fe8d99d8b8f78339ad73186ff1b to your computer and use it in GitHub Desktop.
Save andcam/d8e54fe8d99d8b8f78339ad73186ff1b to your computer and use it in GitHub Desktop.
Wordpress UTF8 chars fix - search & replace
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_title = REPLACE(post_title, '“', '“');
UPDATE wp_posts SET post_title = REPLACE(post_title, '”', '”');
UPDATE wp_posts SET post_title = REPLACE(post_title, '’', '’');
UPDATE wp_posts SET post_title = REPLACE(post_title, '‘', '‘');
UPDATE wp_posts SET post_title = REPLACE(post_title, '—', '–');
UPDATE wp_posts SET post_title = REPLACE(post_title, '–', '—');
UPDATE wp_posts SET post_title = REPLACE(post_title, '•', '-');
UPDATE wp_posts SET post_title = REPLACE(post_title, '…', '…');
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, '“', '“');
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, '”', '”');
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, '’', '’');
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, '‘', '‘');
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, '—', '–');
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, '–', '—');
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, '•', '-');
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, '…', '…');
UPDATE wp_terms SET name = REPLACE(name, '“', '“');
UPDATE wp_terms SET name = REPLACE(name, '”', '”');
UPDATE wp_terms SET name = REPLACE(name, '’', '’');
UPDATE wp_terms SET name = REPLACE(name, '‘', '‘');
UPDATE wp_terms SET name = REPLACE(name, '—', '–');
UPDATE wp_terms SET name = REPLACE(name, '–', '—');
UPDATE wp_terms SET name = REPLACE(name, '•', '-');
UPDATE wp_terms SET name = REPLACE(name, '…', '…');
UPDATE wp_termmeta SET meta_value = REPLACE(meta_value, '“', '“');
UPDATE wp_termmeta SET meta_value = REPLACE(meta_value, '”', '”');
UPDATE wp_termmeta SET meta_value = REPLACE(meta_value, '’', '’');
UPDATE wp_termmeta SET meta_value = REPLACE(meta_value, '‘', '‘');
UPDATE wp_termmeta SET meta_value = REPLACE(meta_value, '—', '–');
UPDATE wp_termmeta SET meta_value = REPLACE(meta_value, '–', '—');
UPDATE wp_termmeta SET meta_value = REPLACE(meta_value, '•', '-');
UPDATE wp_termmeta SET meta_value = REPLACE(meta_value, '…', '…');
UPDATE wp_term_taxonomy SET description = REPLACE(description, '“', '“');
UPDATE wp_term_taxonomy SET description = REPLACE(description, '”', '”');
UPDATE wp_term_taxonomy SET description = REPLACE(description, '’', '’');
UPDATE wp_term_taxonomy SET description = REPLACE(description, '‘', '‘');
UPDATE wp_term_taxonomy SET description = REPLACE(description, '—', '–');
UPDATE wp_term_taxonomy SET description = REPLACE(description, '–', '—');
UPDATE wp_term_taxonomy SET description = REPLACE(description, '•', '-');
UPDATE wp_term_taxonomy SET description = REPLACE(description, '…', '…');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment