Skip to content

Instantly share code, notes, and snippets.

@mohsinrasool
Last active August 29, 2015 14:24
Show Gist options
  • Save mohsinrasool/46d403ac5b822837d899 to your computer and use it in GitHub Desktop.
Save mohsinrasool/46d403ac5b822837d899 to your computer and use it in GitHub Desktop.
WP Queries to fix weird characters (i.e., – = em dash, and — = en dash) in posts and pages
-- Try 1:
-- Change DB_CHARSET from utf-8 to latin1 in wp-config.php
-- define('DB_CHARSET', 'latin1');
-- Try 2:
-- Clean up 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_posts SET post_content = REPLACE(post_content, 'é', 'é');
-- Clean up post title
UPDATE wp_posts SET post_title = REPLACE(post_title, 'é', 'é');
-- Clean up 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, '…', '…');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment