I'd like to make a language switcher, but the default options don't work for me, so I'd like to use the 'raw' attribute. I'm currently just testing whether my languages will show up at all:
$translations = pll_the_languages(array('raw'=>1));
echo $translations[0]['name'];
This code doesn't output anything, but doesn't crash the website either. What am I missing?
you would need to get it like this:
echo $translations['nl']['name'];
It's better to verify if the key exists in the array or not.
$value= "";
if($key_exists('nl',$translations) && $key_exists('name',$translations['nl'])){
$value = $translations['nl']['name'];
}
echo $value;