I created a custom post type and set its permalink structure to ‘category/postname’.
I found that sometimes, when i create a post in a non latin characters, the post slug is getting cut.
I googled and found that the post guid field and post_name field are limited to 255 and 200 characters. and also noticed that the value in these fields (for the non latin slugs) is encoded (like %85%e0%e0%b2%b2%b5%e0%b2%b0%e0%b2) which takes a lot more space.
my database is utf8 encoded and collate is utf8_general_ci. i tried other collations but with no success.
is there any way to fix that so my slug will remain complete no matter what permalink structure is or title length?
Thanks.
No, it is not entirely possible.
WordPress is using Percent encoding to sanitise the slug. You could undo this, and it would deliver nonlatin characters, but the browser would immediately swap these out for percent encoded characters when you tried to visit the page.
Wether your database will store these characters, and the table encoding is irrelevant, as this data is sent over HTTP, and the convention for URLs is ASCII, which does not support those character codes.
As for the length being no more than 255 characters, this is because the slug and post_name columns in the database have a maximum length of 200. You would need to change this to have longer slugs, but I strongly recommend against this.
It’s generally expected that URLs are a strict subset of latin ASCII characters. I’m aware there are nonstandard chinese domains though how they’re dealt with by browsers I’m not sure.