I am using Poly language plugin to build my own custom multi language website

Previously i was using Q_translate it’s working fine with me, but i need to use poly language now, so excuse me if there my experience with poly language is poor.

I need to build my custom language switcher like this website

I am using

pll_current_language();

to get the current language

my problem is i need to call any function to get non-current language.

EX: my website languages is Arabic, English i need let’s say now i am browsing my site in Arabic language i need to get the other language & versus.

I tried this but it’s working

pll_languages_list(array(‘current_lang’=>true));

Thanks in advance

1 Answer
1

You need to use the function pll_the_languages() to get the language switcher.

It has a bunch of arguments which you can use to customise the language switcher:

$args is an optional array parameter. Options are:

‘dropdown’ => displays a list if set to 0, a dropdown list if set to 1 (default: 0)
‘show_names’ => displays language names if set to 1 (default: 1)
‘display_names_as’ => either ‘name’ or ‘slug’ (default: ‘name’)
‘show_flags’ => displays flags if set to 1 (default: 0)
‘hide_if_empty’ => hides languages with no posts (or pages) if set to 1 (default: 1)
‘force_home’ => forces link to homepage if set to 1 (default: 0)
‘echo’ => echoes if set to 1, returns a string if set to 0 (default: 1)
‘hide_if_no_translation’ => hides the language if no translation exists if set to 1 (default: 0)
‘hide_current’=> hides the current language if set to 1 (default: 0)
‘post_id’ => if set, displays links to translations of the post (or page) defined by post_id (default: null)
‘raw’ => use this to create your own custom language switcher (default:0)

The function reference for Polylang is available here: https://polylang.wordpress.com/documentation/documentation-for-developers/functions-reference/

Leave a Reply

Your email address will not be published. Required fields are marked *