Support » Plugin: Polylang » [Plugin: Polylang] home link in menu is not highlighted on home of non-english pages

  • Resolved TuneInTokyo


    1stly, this is a brilliant plugin!!
    I do have a small problem however:

    When i use wp_nav_menu(), the home link isnt being given the class ‘current_page_item’ on the home page of non-english pages. All other pages work properly (the correct link is highlighted for the current page), only the home page link doesnt get the correct class.

    I have noticed that after a query_posts() call, the wp_nav_menu() works as expected and the class is attached to the home link. So a sitemap at the bottom of the page works correctly and home link is highlighted, but a menu call above query_posts() (like in the header, where my main menu is) doesnt work properly.

    To get around this, i have to test if the current page is not an archive or a single page or using any of my templates or an error page.

    While this works, surely there is an easier way….?
    Is this a bug or something that is specific to my site, or something i am doing wrong?

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


    Your problem is probably linked to the fact that I did not filter is_front_page(). See also here.

    But here I believe that I will be able to correct this, as there are probably other ways to modify the class. I will look at that.

    Fair enough. As i said, i was able to find a work around, it just isnt the most elegant. If you had a better way, i would certainly use it.

    To have a look at the site i’m talking about, click here. It isnt live yet so you wont be able to get to the english ‘home’, but you will be able to see the issue in the code on the spanish home page.

    Plugin Author Chouby


    I tried to reproduce and it works well on my test site. However, I use the class .current-menu-item rather than .current_page_item (which should appear only for pages and thus not on custom links). I supposed you are using custom links to setup your home links. Am I right ?

    But curiously, on your site all the serie of classes .menu-item .current-menu-item .menu-item-xxx .menu-item-type-yyy .menu-item-object-zzz does not appear. And I do not understand why since according to what I understood from the WordPress code, they should always be here. Except if a plugin removes them after WordPress set them…

    That is strange. No, i just wp_nav_menu() with an argument of ‘show_home’ = true, to draw the menu. All the items in the menu are pages. And it works fine on the english home page, which is why i thought it could be to do with polylang.

    That is the strangest part, and the classes like ‘home’ dont get applied to the body either. But on english home, they are applied as expected.

    I dont think i have any plugins that would be interfering (i just tested the site with all my plugins deactivated except polylang and i seem to get the same result. That is: no classes are assigned to the ‘inicio’ main-menu link.) So i’m thinking its not another plugin.

    Plugin Author Chouby


    I believe that I start to understand… Correct me if I am wrong. You did not set up a custom menu in the WordPress admin. You just put somewhere in your theme:
    wp_nav_menu( array('show_home' => true ) );

    Thus since the parameter theme_location is not present, WordPress creates its own menus based on pages using the function wp_page_menu. This explains that you css classes are not the same as mine.

    Well… I did not filter this function yet, which explains why it does not work correctly for translated home. I will see what I can do.

    Plugin Author Chouby


    If your problem is what I described above, then it will be corrected in version 0.5.

    That’s exactly right. Yeah, i think it uses the fallback wp_page_menu().

    That would be brilliant, thanks so much!

    I see that its now working with the new update!
    Brilliant! Thanks so much for you help and hard work!

    Hey Chouby,

    Just thought i would let you know, there is another small bug related to this problem.

    ‘current_page_item’ is now added to the homepage link on archive pages on all languages.

    you can see the problem here.

    Plugin Author Chouby


    Is it something which worked before and was broken by the last update ?

    I think it may have been. I didnt notice this problem before the last update.

    Plugin Author Chouby


    I just went back to your link and the problem has disappeared. Did you make something ?

    Yeah, i did a bit of a hack to hide that style on the affected pages.

    If you have a look at the source code, you should be able to see that the class is still being applied to the home tab, when it shouldnt be.

    That old link may not work now, try this one instead.

    Plugin Author Chouby


    Yes it’s clear. The problem is that I do not reproduce the bug on my test site 🙁 . That’s why I went back to your site to see what could differ. I will look at this more closely.

    That’s strange.

    I tried disabling polylang and the class was no longer applied incorrectly, that is the only reason i thought it was was something to do with this plugin.

Viewing 15 replies - 1 through 15 (of 25 total)
  • The topic ‘[Plugin: Polylang] home link in menu is not highlighted on home of non-english pages’ is closed to new replies.