I created a menu inside a theme I'm creating and have added a language switcher that comes with Polylang.
On the fronted the switcher shows up as it should, but it shows the full name of the language (eg. English, Deutsch,...). Instead of full names, I would like country codes to be printed.
Now:
Wanted result:
You achieve this in two ways:
adding
'display_names_as'=>'slug'
to the args$args = array('show_flags' => 0, 'show_names' => 0, 'hide_current' => false,'dropdown' => 1,'display_names_as'=>'slug'); pll_the_languages($args);
Or
Polylang hook Just add this snippet in your function.php file:
add_filter( 'pll_the_languages_args', function( $args ) { $args['display_names_as'] = 'slug'; return $args; } );