WordPress Shortcodes provide a convenient way to create complex content in the WordPress post editor. In addition, you can use shortcodes in PHP files by using the do_shortcode() function.
The following shortcodes are available for WPML since the version 3.2.
wpml_language_selector_widget
- Display WPML’s drop-down language switcher.
- This is similar to the wpml_add_language_selector hook.
- To customize the output of this shortcode, go to WPML → Languages and use the settings in the Custom language switcher section.
wpml_language_selector_footer
- Display WPML’s horizontal language switcher.
- The output of this shortcode is exactly the same as for the wpml_footer_language_selector hook.
- To customize the output of this shortcode, go to WPML→ Languages and use the settings in the Footer language switcher section.
wpml_language_form_field
- Make a custom search form multilingual-ready.
- The output of this shortcode is exactly the same as for the wpml_add_language_form_field hook.
wpml-string
- Example:
[wpml-string context="my-domain" name="my-name"]My string[/wpml-string]
- Register and translate a string. This shortcode requires WPML String Translation to be active.
- To translate this string, go to WPML → String Translation and use the following informationg (replacing the names with your own):
- Domain: my-domain
- Name: my-name
- String: My string
- Note that in order for the strings to be registered and available for translation, you first need to visit the pages that feature them on the front-end.
wpml_language_switcher
- This shortcode is available since WPML 3.6.0 version.
- Example:
[wpml_language_switcher type="footer" flags=1 native=1 translated=1][/wpml_language_switcher]
- Arguments:
- type – Define the language switcher type: footer, post_translations, widget or custom (default).
- flags (alias for display_flags) – Use 1 to display flags and 0 not to.
- link_current (alias for display_link_for_current_lang ) – Use 1 to display links and 0 not to.
- native (alias for display_names_in_native_lang ) – Use 1 to display native language names and 0 not to.
- translated (alias for display_names_in_current_lang ) – Use 1 to display language names in the current language and 0 not to.
- template – The template slug if it needs to be overwritten. Otherwise, it will be defined by the type.
- For the type parameter, WPML uses settings from the WPML → Languages page, except widgets which use the default settings.