How to translate “Custom Post Types”
To translate accordion post type you should use the WPML plugin that allows you to translate all custom post types that come with your themes or plugins.
To set the accordion custom post type, you will need to install and activate WPML’s core plugin (Sitepress multilingual CMS) along with the Translation Management add-on.
- Navigate to WPML -> Translation Management and click on the Multilingual Content Setup tab and scroll down to the Custom Posts section.
- Set the custom post type Accordion to be translated.
- Click on the Save button.
- Navigate to Accordions -> All Accordions. Click on the + icon to add your translation
- Click on the Copy content from English button.
- Add your translated text and click on the Publish button
If you are running a multilingual website, you will want to translate your custom post types, custom field type, and custom taxonomies. WPML can translate all these elements efficiently.
Awesome Accordions Shortcode
Awesome accordions come with multi-language support, you can create and translate accordions in your preferred language. Awesome accordions plugin supports WPML translation and you can display accordions in different languages by simply changing the ID parameter in the shortcode.
After creating the accordion a shortcode is generated that you use to publish the accordion in pages and posts. The shortcode has an Id that is equal to the page ID assigned to the specific accordion custom post when it is created:
To publish the accordion you should copy the shortcode as shown in the image above and paste it in the page or post where you would like to display the accordion.
To publish multi-language accordion you should begin by creating the accordion and translating it to another language.
For example, you can create the accordion in English then translate to Dutch using the WPML plugin. Click on the add sign to add the translated version of the accordion.
After the translation, you have two similar accordions with different page IDs. You can switch between the different translations using the menu on the top as shown below:
Publishing Multi-Language Accordions
You should get the page ID of each of the different version of the accordion that has been created and translated and use it in the awesome-accordions shortcode.
Create a new page and add the shortcode replacing the ID with the respective page ID of the accordion you wish to display. As shown below:
For the translated accordion you need to include the original shortcode published in the step above and the corresponding shortcode with the ID of the respectively translated accordion as shown below:
How the Shortcode Translation Function works
The post with the EN shortcode is displayed while for the other versions the shortcode functions check if the translated ID example FR-ID exists and if it does the translated version is shown and if not the English version is displayed.