WordPress.org

Forums

Polylang
[resolved] Language switch always redirects me to the Front page (5 posts)

  1. Palic
    Member
    Posted 2 years ago #

    Hi,
    Thanks a lot for this great plugin !
    I'm starting using wordpress 3.4.2 and downloaded the 0.9.1 version of polylang.

    My problem is that when I use the language switcher, polylang redirects me to the front page (mywebsite.com/?lang=en or mywebsite.com/?lang=fr) instead of redirecting me to the corresponding translated page (mywebsite/?page_id=xx). (not all the pages are translated but all are at least set with the default language)
    Switch between front pages (fr and en) works perfectly but I would like to be able to switch from one page to another without going thru all the translated menu)

    More information :
    I did'nt use the polylang widget : I only added this code in my sidebar

    <!-- option multilingue -->
    <ul><?php pll_the_languages(array('show_flags'=>1,'show_names'=>1,'force_home'=>0));?></ul>
    <!-- -->

    I don't use custom menu neither : In my header, I use this code to generate the menu and to switch it from french (id6329) to english (id192)

    <ul id="dropmenu">
    
    <?php if(pll_current_language('slug') == "en"){
    	wp_list_pages('sort_column=menu_order&child_of=192&title_li='); }
    elseif(pll_current_language('slug') == "fr"){
    	wp_list_pages('sort_column=menu_order&child_of=6329&title_li='); }
    ?>

    I'm a beginner in php and web site development so I'm probably doing something wrong. Can you help me ?

    Many thanks.

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

  2. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    your usage of pll_the_languages looks good. Have you a link to your site?

  3. Palic
    Member
    Posted 2 years ago #

    Thank you Chouby for your quick answer

    My website is http://infrenchwithenglishsubtitles.com
    I'm using the Equilibrium theme.
    You'll find the french/english switch buttons on the "search zone"

    All the pages of the website are stil not translated
    In the english version, you can go for example to "About us --> Who we are" (http://infrenchwithenglishsubtitles.com/?page_id=155)
    Then click on the french flag. The page "L'equipe --> qui sommes nous" (http://infrenchwithenglishsubtitles.com/?page_id=6333) is supposed to appear but instead of it I'm redirected to the french home page.
    In other terms, it almost works but I would like to stay on the same page instead of going back to the front page.

    I'm sure it's something simple I didn't notice but my php background is too limited yet to solve it. A question I'm asking to myself for example is how does polylang switch from a page_id to its translated "twin" and reconstructs in the same time the header and the menu ?

    Many thanks for all,
    Palic

  4. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    It's strange because the translated page is correct in the <head> section, meaning that the pages are correctly linked together and that Polylang is able to find the translation, so should be able to find it again in the switcher.

    I downloaded your theme, made a test with the widget and it works perfect.

    Could you try with the standard language switcher widget (of course, keeping the option "Forces link to front page" unchecked)?

  5. Palic
    Member
    Posted 2 years ago #

    Hi Chouby.
    It works prefectly now !!! Thanks a lot !

    I tried to insert it as a widget and it worked.
    So I went back to my previous code and noticed that the code

    <!-- option multilingue -->
    <ul><?php pll_the_languages(array('show_flags'=>1,'show_names'=>1,'force_home'=>0));?></ul>
     <!-- -->

    was not inserted inside the widget section below

    <div id="sidebar">
    
    <ul>
    <?php 	/* Widgetized sidebar, if you have the plugin installed. */
    if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
    
    <!-- Place pll_the_languages inside the widget section and it works -->
    
    <div class="clear"></div>

    This plugin is wonderful !
    Thanks a lot for your help !

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Polylang
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic