Learn how to set translation settings for custom post types and taxonomy terms you register in your code. WPML allows you to configure these settings in the wpml-config.xml file.
The wpml-config.xml is a configuration file that instructs WPML how it should treat elements in your themes and plugins. You can use it to define which of your custom types and taxonomies should be translated, and how.
This guide is for developers who register custom terms, post types, or taxonomies in their own custom code. If you use a third-party plugin for this, read our pages about translating custom post types and custom taxonomies.
Need to generate a wpml-config.xml file? Visit our step-by-step guide for automatically generating a configuration file using the Multilingual Tools plugin.
Registering Custom Post Types
To translate custom post types you need to specify the post type name and set the translate attribute to 1. This indicates that the custom type should be translated (use 1 to translate, and 0 not to translate).
<wpml-config>
<custom-types>
<custom-type translate="1">book</custom-type>
<custom-type translate="1">DVD</custom-type>
</custom-types>
</wpml-config>
You can add the display-as-translated attribute to the tag to show the post types in the default language if no translation exists.
<wpml-config>
<custom-types>
<custom-type translate="1" display-as-translated="1">movie</custom-type>
</custom-types>
</wpml-config>
You can add the automatic attribute to the tag to exclude a post type from automatic translation when using the Translate Everything Automatically mode. If you use this attribute, your entire language configuration file will only work for WPML versions 4.5.0 and up.
<wpml-config>
<custom-types>
<custom-type translate="1" automatic="0">contact_form</custom-type>
</custom-types>
</wpml-config>
Registering Custom Taxonomies
To translate custom taxonomies you need to specify the taxonomy name and set the translate attribute to 1.
<wpml-config>
<taxonomies>
<taxonomy translate="1">genre</taxonomy>
<taxonomy translate="1">type</taxonomy>
<taxonomy translate="0">publisher</taxonomy>
</taxonomies>
</wpml-config>
Tip: if you have taxonomies that don’t need translation you can simply omit them from this list.
You can add the display-as-translated attribute to the tag to show the taxonomies in the default language if no translation exists.
<wpml-config>
<taxonomies>
<taxonomy translate="1" display-as-translated="1">wild-west</taxonomy>
</taxonomies>
</wpml-config>
Additional Resources
To learn more about the wpml-config.xml file, visit the Language Configuration Files guide.
For customizing other elements using the wpml-config.xml file, visit our additional guides:
- Translate Custom Shortcodes with WPML
- Register Page Builder Content for Translation
- Register Custom Page Builder Widgets for Translation
- Set Translation Options for Custom Fields Using WPML Configuration File
- Make Custom Gutenberg Blocks Translatable
- Translate Texts that Theme and Plugins Save in wp_options
- Customize WPML Language Switcher Using WPML Configuration File