Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

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.

share|improve this answer
    
Hi Tom, Thank you for your answer. How can i undo the sanitize for the slug? i don't mind the browser to show the percent encoding at the address bar, the thing is i migrated an old site to WordPress and i want to keep the url structure. so if i can keep the slug in non latin and full length it will do the work. Thanks again. –  spartacus Mar 29 '12 at 12:01
    
hmm the old site would have converted to percent encoding though? I don't think it can be done cleanly –  Tom J Nowell Mar 29 '12 at 12:59
    
old site didn't convert the slug/url to percent encoding. i stored the slug as-is in the db, and the browser also showed it correctly. –  spartacus Apr 1 '12 at 9:17
    
I found a trac ticket discussing the issue, but it seemed to be closed 2 years ago: link –  spartacus Apr 1 '12 at 9:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.