I am making an plugin, and inside my admin page (Which i add by add_menu_page()
function) i call this function pll_the_languages(["raw" => 1]))
but its return nothing,on client side its work fine.
I added many languages on Polylang setting page.
How can i get Polylang available languages from an admin page ?
3 Answers
According to Polylangs Function Reference, pll_the_languages
Displays a language switcher.
And most probably it uses some additional CSS/JS to work. If you want to get the list of languages and display them with your custom code, then you can use this function instead:
pll_languages_list($args);
and it will return the list of languages.
$args is an optional array parameter. Options are:
- ‘hide_empty’ => hides languages with no posts if set to 1 (default: 0)
- ‘fields’ => returns only that field if set. Possible values are
‘slug’, ‘locale’, ‘name’, defaults to ‘slug’