Support » Plugin: Polylang » [Plugin: Polylang] Language switcher in custom place in template

  • Resolved christos312

    (@christos312)


    Hello, I want to show the language switcher somewhere in the template that there is no available widget area.

    I search the documentation and I found that I can use this function

    <?php pll_the_languages();?>

    Sadly I get this error

    Fatal error: Call to undefined function php�pll_the_languages()

    The function has been renamed? or doesn’t exist yet?

    http://wordpress.org/extend/plugins/polylang/

Viewing 7 replies - 1 through 7 (of 7 total)
  • 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.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: Polylang] Language switcher in custom place in template’ is closed to new replies.