Plugin Author
Chouby
(@chouby)
The function exists and that’s strange that it does not work called from a template file. Such error will occur, of course, if the function is used before Polylang is loaded. In which file did you put the line?
I want to have the switcher to the header so I called it in the header.php file.
When does Polylang is loaded?
Plugin Author
Chouby
(@chouby)
Polylang is loaded by WordPress as other plugins so much before the template files are loaded. Have you a link to your site?
My wordpress is locally installed so I cannot give you any URL’s
But to be specific I tried to load the function in the header.php file in the twentyeleven template, just after the search bar.
And I got the error I pasted above.
I will try to load it to the index.php and see what is going on.
Thanks for your answer I will report back soon.
Plugin Author
Chouby
(@chouby)
Works perfect for me like this in the header.php of Twenty Eleven:
...
<?php
else :
?>
<?php get_search_form(); ?>
<?php endif; ?>
<?php pll_the_languages(); ?>
<nav id="access" role="navigation">
...
Ok I have found the error…
I copied and pasted the code from the documentation and an invisible character was inserted to my code
php�pll_the_languages()
That ? sign, was causing the error.
Another question that I have is:
Is there a way to show flags as well? When I am calling the function?
Thanks for your time and effort
Edit nevermind found it 😉
Thanks @christos !
I had the same issue.