WPML Hooks API
WPML 3.2 offers filter and action hooks that can be used in your WordPress theme or plugin to provide correct multilingual support. Browse the Hooks Reference API for details of each hook
WordPress Shortcode provides a convenient way to create complex content in the WordPress post editor. In addition, you can use shortcodes in PHP files by calling the function do_shortcode(). Since WPML 3.2, we provide the following WPML shortcodes:
[wpml_language_selector_widget]– Display WPML’s drop-down language switcher. This is similar to the hook wpml_add_language_selector.
[wpml_language_selector_footer]– Display WPML’s horizontal language switcher. The output of this shortcode is exactly the same as for the hook wpml_footer_language_selector.
[wpml_language_form_field]– Make a custom search form multilingual-ready. The output of this shortcode is exactly the same as for the hook wpml_add_language_form_field.
[wpml-string context="my-domain" name="my-name" ]My string[/wpml-string]– Register and translate a string. This shortcode requires the plugin WPML String Translation to be active. To translate this string, go to WPML->String Translation and use the following info:
- Domain: my-domain
- Name: my-name
- String: My string
WPML defines the following constants which can be used in the theme:
|ICL_LANGUAGE_CODE||Code for the current language||fr|
|ICL_LANGUAGE_NAME||Name of current language, in the current language||Français|
|ICL_LANGUAGE_NAME_EN||Name of the current language name in English||French|
WPML comes with its own CSS and JS files that style its navigation and drop-down language switcher.
If you don’t need them in your theme, you can tell WPML not to load these files. Do to that, define the following constants in your theme:
|Constant||The file it disables|
|ICL_DONT_LOAD_NAVIGATION_CSS||Navigation stylesheets – cms-navigation-base.css and cms-navigation.css|
|ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS||Drop-down language selector stylesheet – language-selector.css|
To set these constants, define them in the theme’s functions.php file. For example: