Friday, November 20, 2015

WordPress displays weird characters

Sometimes after a database conversion (e.g. from MySQL to MariaDB) or due to encoding issues a situation might arise when WordPress is showing weird characters. A quick way of remedying the situation would involve examining the pages to discover a pattern (what characters are being substituted, in the example below the apostrophe was replaced by â€™) then running an queries against the database to reverse the effect. Here's a quick example (common tables that store content):



  • UPDATE wp_posts SET post_content = REPLACE(post_content, 'Â''')     
  • UPDATE wp_posts SET post_content = REPLACE(post_content, '’'"'")     
  • UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, 'Â''')     
  • UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, '’'"'")     

  • Please, keep in mind that to permanently resolve the issue you would need to get to the root of the problem and may need to adjust encoding, run a database conversion, or install a sanitizing plugin.

    No comments:

    Post a Comment