Language switching header.php - by heinpoblome@gmail.com

This topic has 2 replies, 2 voices, and was last updated 7 years, 8 months ago ago by Robert Hall

  • Avatar: heinpoblome@gmail.com
    heinpoblome@gmail.com
    Participant
    August 5, 2016 at 18:47

    I might be asking a WP question here, but in the theme’s header.php there is a section for the languages.

    I have WPML structuring the different languages in directory format, and no longer in ?lang= format.

    When I used the top bar to switch languages with the ?lang format, it change the language, and stayed on the same page, which is what I wanted.

    I do not know how to achieve the same with the /en/ format of url’s. How do I switch language while staying on the same page ?

    <ul class=”links”>

    <ul>
    <li><a href=”/fr/#”>FR>/a<>/li>
    <li><a href=”/nl/#”>NL</a></li>
    </ul>
     

    brings the right language, but always the home-page

    1 Answer
    Avatar: Robert Hall
    Robert Hall
    Support staff
    August 6, 2016 at 10:52

    Hello,

    Try to use the following code

    <ul class=”links”>
    <li><a href="<?php echo '/fr' . $_SERVER["REQUEST_URI"] ?>">FR</a></li>
    <li><a href="<?php echo '/nl' . $_SERVER["REQUEST_URI"] ?>">NL</a></li>
    </ul>

    Regards,
    Robert Hall

  • Viewing 2 results - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.