WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. TMNR
    Member
    Posted 1 year ago #

    ***INFO***

    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.

    ***Question***
    Hi,
    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?

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

  2. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

  3. TMNR
    Member
    Posted 1 year 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
    Member
    Plugin Author

    Posted 1 year 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
    Member
    Posted 1 year 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
    Member
    Plugin Author

    Posted 1 year ago #

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

  7. TMNR
    Member
    Posted 1 year 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
    Member
    Plugin Author

    Posted 1 year 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:
    </hgroup>
    (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
    Member
    Posted 1 year 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

About this Topic

Tags