anonymized-13603639
(@anonymized-13603639)
Yes, you can. Display slug instead of name. Or edit name from “English” to “EN”.
Hello,
thanks for the help! I know how to edit the language names – great idea! But how can I change it to display the slug?
Thank you and regards –
Arne
anonymized-13603639
(@anonymized-13603639)
Check out Polylang function reference at https://polylang.wordpress.com/documentation/documentation-for-developers/functions-reference/
As you can see pll_the_languages() allows you to use some arguments. With
<?php pll_the_languages(array('display_names_as'=>'slug')); ?>
you display the slug instead of the name.
Put this code line in your theme where you want to get the language switcher.
How to use custom language names then?
I want to change to something other than the code
I was looking for a solution to this issue and one of the first google results led to this page. My situation is a bit different as I want to use a standard Polylang widget in navigation menu, and calling <?php pll_the_languages(array(‘display_names_as’=>’slug’)); ?> does not solve this. So, I’ve studied the code and found a useful filter ‘pll_the_languages_args’. And I wrote this code to change the value from functions.php:
/**
* Display languages as slugs instead of full name.
*
* @param $args array Merged array of defaults and user settings for language selector
*
* @return array Modified array of arguments
*/
function pss_language_as_slug( $args ) {
$args['display_names_as'] = 'slug';
return $args;
}
add_filter( 'pll_the_languages_args', 'pss_language_as_slug', 10, 1 );
Hope this will help someone.
@ihor Vornotov a gold one, than you!