function language_switcher_fun( $atts ){
ob_start();
do_action('wpml_add_language_selector');
return ob_get_clean();
}
add_shortcode( 'language_switcher_shortcode', 'language_switcher_fun' );
Code language: PHP (php)
The do_action('wpml_add_language_selector');
action outputs the language switcher based on the options set in the Custom Language Switchers section in WPML ? Languages.
You can use it like this [language_switcher_shortcode]