CODE CODIFY.CLUB

Fix HTML characters encoding issues In WordPress

If you have switched web host, or changed the database for your WordPress blog, you might encounter an issue where foreign characters are not showing up properly in your site. Instead of the foreign characters, you will see plenty of question marks (???) in its place.  Well let’s see how to fix them.

Did you see “?” in your WordPress ?

There can be a few causes that lead to displaying the wrong characters. First of all, you need to make sure that you are using the same character set in your wp-config.php file. Look for the following line and make sure it is not commented out:
define('DB_CHARSET', 'utf8');
Now, you need to check if your theme is using the character set that is set in wp-config.php file. Look for the following line in your HTML:
<meta charset="UTF-8" />
And lastly, you need to check that your database content is stored with the same character set encoding that you are using in your wp-config.php file and HTML. If you are using phpMyAdmin to manage your database, you will be able to see the current server collation in General Settings.

Changing the character set of complete WordPress database is not an easy task and should be done with a lot of care. Here are the steps to convert a database to your character set of choice.
1. First of all, we need to check the current character set of the database. Here’s the SQL query for checking:
SHOW VARIABLES LIKE "character_set_database";
2. If the character set is not what you want, you should take a backup of your database before you proceed further.
3. Run the following SQL query to change the characater set of complete database:
ALTER DATABASE MyDb CHARACTER SET utf8;
Change “MyDB” to the name of your database.
4. Now convert the “wp-posts” table to the character encoding you want:
ALTER TABLE wp_posts CHARACTER SET utf8;
Change the “wp_” if you are using a different prefix.
These steps will remove the question marks or other weird characters and will show proper foreign characters instead. If you have many columns in the WordPress database that are set to custom character set, you will need to change the character set of each column one by one.





V!ral

Developer, Technology aficionado, Beer Lover and founder of codify.club Network. Who shares a keen interest about website development, health issues, cancer awareness and other fun stuff.

Add comment

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.

Most popular

Most discussed