Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Polylang language switcher - show only language codes

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:

enter image description here

Wanted result:

enter image description here

like image 532
dodo254 Avatar asked Oct 24 '25 02:10

dodo254


1 Answers

You achieve this in two ways:

  1. 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

  1. 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; } );

like image 56
nemo Avatar answered Oct 27 '25 02:10

nemo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!