I have an issue with a friend's WordPress website I recently migrated to my personal web-server. I have never used WordPress besides setting up my blog (which runs fine). But with this website, I am having a hard time. It seems like every time we attempt to save a post or a page, the content gets saved as weird characters (boxes, question marks, etc).
Sounds like a pretty common issue people are having with WordPress but it's not. That's because the encoding issue only happens when saving something using the WordPress editor. For example, if I directly input greek characters via MySQL Workbench, they will be correctly displayed on the page. But if I edit the page, all non-english characters (even those that used to be displayed correctly), will be stored as gibberish. And by store I mean, I can see those characters looking like this: γιΠinside the wp_posts
table.
So WordPress can read non-English characters from the database but it cannot write non-english characters to the database.
DB_COLLATE
is set to utf8mb4_general_ci
and DB_CHARSET
to utf8mb4
.
MySQL Workbench reports the same for the database. My blog, that runs on the same server, using the same WordPress version and the same database, works fine.
Use utf8_decode
and utf8_encode
in save query method.
Open the file wp-config.php
in the main directory of the website.
There is a line which should read define('DB_CHARSET', 'utf8mb4');
If not, change or add that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.