• Resolved russclem

    (@russclem)


    Hi there,

    First, love your plugin, it’s easily the best I’ve tried for translation. Super simple to use, and well designed.

    But, I have a question. 🙂

    I’ve made my own language switcher, which is embedded in header.php – it works fine but currently it’s a bit static. It only links to the main site, and the English translation of the main site, and it does that on every page. Instead, I want it to link directly to the translated version of the current page.

    How do I achieve that?

    Many thanks!

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Chouby

    (@chouby)

    Hi,

    You can use the function pll_the_languages, possibly with the ‘raw’ options to get all the information that you need for a custom language switcher. See: https://polylang.pro/doc/function-reference/

    Thread Starter russclem

    (@russclem)

    Okay, so this is what I’ve got so far:

    <?php $translations = pll_the_languages(array('raw' => 1)); ?>
                    <div class="lang-item-no">
                        <a href="<?php echo $translations[0]['url']; ?>">NO</a>
                    </div>

    But this just returns a link for the current translation. How do I make it return the link for a different, specified translation?

    • This reply was modified 7 years, 7 months ago by russclem.
    • This reply was modified 7 years, 7 months ago by russclem.
    Thread Starter russclem

    (@russclem)

    Nevermind, solved it.

    I just needed to replace $translations[0] with $translations[en] or whatever language code I needed.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Link to same page in different language’ is closed to new replies.