Background of the issue:
Our WordPress website uses WPML to support multiple languages. We want to change the language slugs from /zh-hans/ to /zh/ for Simplified Chinese and from /zh-hant/ to /tw/ for Traditional Chinese. We have tried using the wpml_language_url filter, wpml_get_home_url filter, and manually rewriting URLs via the rewrite_rules_array hook in functions.php without success. We checked WPML settings, but the UI does not allow direct modification of language codes. The new URLs should replace the current ones while preserving all translations and SEO settings.
Symptoms:
Unable to change WPML language slugs from /zh-hans/ to /zh/ and /zh-hant/ to /tw/ using available methods.
Questions:
Does WPML officially support changing language slugs?
Is there a proper way to change language slugs without breaking existing translations?
Thank you for contacting WPML support. While you are waiting for one of my colleagues to take this ticket and work on it, let me provide you with first debugging steps or if I can perhaps help with the issue quickly.
Please note that by design it is not possible to edit the language code of default languages.
However, you would be able to add a new custom language ( Chinese(Simplified) ) with your custom language code(zh).
Since you already have content in Chinese Simplified, you can duplicate the existent "Zh-hans" content in the new language "zh".
If that does not help, one of my colleagues will soon come to continue support.
The topic ‘[Closed] How to change WPML language slugs from zh-hans to zh and zh-hant to tw?’ is closed to new replies.
Manage Cookie Consent
We use cookies to optimize our website and services. Your consent allows us to process data such as browsing behavior. Not consenting may affect some features.
Functional
Always active
Required for our website to operate and communicate correctly.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
We use these to analyze the statistics of our site. Collected information is completely anonymous.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
These cookies track your browsing to provide ads relevant to you.