[resolved] Using pll_the_languages(); in Twenty Eleven child theme (9 posts)

  1. TMNR
    Posted 3 years ago #


    Twenty Eleven Child Theme
    No other plugins

    1. Permalink settings - default
    2. Static front page is used
    3. Settings:
    Detect browser language - N
    The language is set from content - Y
    Remove /language/ in pretty permalinks - Y
    Hide URL language information for default language - N
    When using static front page... - N
    Allow to synchronize categories - N

    I've read the documentation.

    I have successfully set up 3 languages and it works fine with Displays a language switcher at the end of the menu option. But i want to add language chooser to my header. In documentation there's a mention of pll_the_languages(); function and some examples, but i can't seem to get it to work.

    I have created header.php in my child theme and tried to add one of the examples, but it breaks the site. What am i doing wrong? Am i missing something?


  2. Chouby
    Plugin Author

    Posted 3 years ago #

  3. TMNR
    Posted 3 years ago #

    I've read all available threads on this issue. Still can't get it to run. Now tell me if i'm wrong, but to test this function i've tried to add
    <ul><?php pll_the_languages(); ?></ul> one of my pages content area in HTML mode (via WordPress dashboard). Also tried the same line in header.php, i mentioned previously - it breaks the CSS. Unfortunately no link 'cause i'm on a local dev server.

  4. Chouby
    Plugin Author

    Posted 3 years ago #

    Sorry. I did not understand first that only your CSS was broken. It's quite logical it is as Twenty Eleven has not been designed with this modification in mind. However I can't help if I don't know where you put the code and the result you want to obtain.

  5. TMNR
    Posted 3 years ago #

    As i said before - i want it to be in the header. So my first thought was to put the line in the header.php (notice that i'm using a child theme). So what are my options?

  6. Chouby
    Plugin Author

    Posted 3 years ago #

    Could you post your code? And tell me what is wrong in the result you obtain.

  7. TMNR
    Posted 3 years ago #

    In a child theme folder i create a new file called header.php and i add <ul><?php pll_the_languages(); ?></ul> inside it. This supposed to add this line to the parent header.php file without compromising the original file, but i'm sure you know how child theme works.

    To say in other words - i have a stock twenty eleven theme (no modifications) and i want to add a language selector to my header. What do i do? Because my method described above does not work.

  8. Chouby
    Plugin Author

    Posted 3 years ago #

    Does your header.php in your child theme contain only this line?
    You must copy paste all the content of the original header.php in the file of your child theme and just add:
    <ul><?php pll_the_languages(); ?></ul>
    where you want it, for example after:
    (that would be pure luck that you want it here).

    Then you will need to add CSS rules to design it as you want.

  9. TMNR
    Posted 3 years ago #

    It worked! I guess my main error was that i thought it would suffice to add only the line that i wanted. All i had to do is copy the whole content in to my child header.php. That's me, always not paying enough attention to stuff. Thank you for your patience and happy Holidays!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Polylang
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic