Polylang language switcher - show only language codes

Viewed 4507

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

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

Related