add_action( 'wpml_language_has_switched', callable $function_to_add );
- Type
- action
- Category
- Site-Wide Language Information
- WPML Version
- 3.2.7
Description
- Run your custom functions right after switching the global current language in WordPress queries.
- To change the current language, use the wpml_switch_language hook.
WPML passes the language code to your callback. Since WPML 5.0, this action also runs when a caller restores a language switch. In that case, the language code is null. See wpml_switch_language for how language scopes open and close.
Arguments
- $function_to_add
- (callable) (Required) Your callback to be run when the filter is applied.
Example usage
Example
function my_plugin_actions() {
// These actions will be executed right after the global current language has just changed.
}
add_action( 'wpml_language_has_switched', 'my_plugin_actions' );
Related hooks
wpml_decode_custom_field, wpml_footer_language_selector, wpml_add_language_form_field, wpml_ls_exclude_in_menu, wpml_is_rtl, wpml_alternate_hreflang, wpml_head_langs, wpml_must_translate_canonical_url, wpml_browser_redirect_language_params, wpml_active_languages