WordPress: Customize Polylang Language Switcher
A default language switcher for Polylang it’s a bit out of date. Below are the customized Polylang Language Switcher.

Below are the codes used for the customization.
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); // check if polylang exist & enabled if ( is_plugin_active( 'polylang/polylang.php' ) ) { //plugin is activated add_filter('pll_the_languages', 'my_dropdown', 10, 2); function my_dropdown($output, $args) { $translations = pll_the_languages(array('raw'=>1)); $output = ''; $output .= '<div class="btn-group" role="group"> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> '.$args['title'].' <span class="caret"></span> </button> <ul class="dropdown-menu">'; foreach ($translations as $key => $value) { $output .= '<li><a href="'.$value['url'].'"><img src="'.$value['flag'].'" alt="'.$value['slug'].'"> ' .$value['name'].'</a></li>'; } $output .= '</ul></div>'; return $output; } }
References:
where should I add this customization !
Should i add this to header.php ?