2

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

2

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/

1
  • Thanks for your support, i need to custom the HTML so i can implement it with JQuery to get the final as same as above Example, so i need to get every language separated with itself as ( current language, non-current language), so yet now i am trying to figure this by the above way, but you are guided me for very important information, hide_current ,, i will try to use it
    – adnan
    Jan 28 '16 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.