WordPress.org

Ready to get started?Download WordPress

Forums

Polylang
[resolved] home link in menu is not highlighted on home of non-english pages (26 posts)

  1. TuneInTokyo
    Member
    Posted 2 years ago #

    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?

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

  2. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    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.

  3. TuneInTokyo
    Member
    Posted 2 years ago #

    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.

  4. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    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...

  5. TuneInTokyo
    Member
    Posted 2 years ago #

    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.

  6. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    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.

  7. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

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

  8. TuneInTokyo
    Member
    Posted 2 years ago #

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

    That would be brilliant, thanks so much!

  9. TuneInTokyo
    Member
    Posted 2 years ago #

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

  10. TuneInTokyo
    Member
    Posted 2 years ago #

    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.

  11. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

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

  12. TuneInTokyo
    Member
    Posted 2 years ago #

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

  13. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

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

  14. TuneInTokyo
    Member
    Posted 2 years ago #

    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.

  15. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    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.

  16. TuneInTokyo
    Member
    Posted 2 years ago #

    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.

  17. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    It's not because I do not reproduce the bug that your problem does not come from polylang. I don't like the way I was obliged to make things 'work'. So problems may rise especially if another plugin or theme is playing with the same filter. I did not look yet, as it does not seem to be urgent since you found yourself a workaround. But trying to correct this is in my TODO list for v0.6.

  18. TuneInTokyo
    Member
    Posted 2 years ago #

    Thanks Chouby!!
    As you said, my fix is okay for the time being, i'll test further when you release the next version.

  19. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    To be honest, I spent some hours on this issue, and did not succeed yet to find a valid solution. I did not reproduce the bug yet. Even on your site, it "randomly" works sometime (I looked at the classes displayed on the source code), which is very curious.

  20. TuneInTokyo
    Member
    Posted 2 years ago #

    That is very strange. Must be a conflict with another plugin or something.
    It doesnt even seem to work randomly for me.

  21. TuneInTokyo
    Member
    Posted 2 years ago #

    I just noticed another strange problem...my archive links have disappeared. Any call to wp_get_archives doesnt work and it seems like next_posts_link and previous_posts_link dont work either on those pages.
    It seems to have broken since the last polylang update i think.

    i disable all plugins...the archive and next/previous links are there.
    i leave everything disabled and reactivate polylang...the links are gone.

    could this be something i have done in my theme or settings, or could my install of polylang be broken somehow? or perhaps my wordpress install?

    everything else seems to be working perfectly though. very confusing.

  22. TuneInTokyo
    Member
    Posted 2 years ago #

    i have temporarily gone back to 0.51.
    archive links are now working again.

    must be something in the 0.6 version i guess?

  23. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    Yes. Bad regression already reported (seems to be the most annoying bug of 0.6). 0.6.1 will fix it soon.

  24. Chouby
    Member
    Plugin Author

    Posted 2 years ago #

    YES !!!!!! At last, I believe that I found the origin of the problem.

    Before, I did not notice that you highlight the 'news' menus on several different pages (news page + archive page). I noticed a different html code (I even wrote that "it works randomly") but did not look carefully at the url I was browsing...

    Coming back on the issue, I noticed this time that the problem is on archives pages only and finally it took few minutes to find a correction.

    So I hope the 0.6.1 will correct the problem for you too.

  25. TuneInTokyo
    Member
    Posted 2 years ago #

    Brilliant!!!

    Ahhh, good work! I'm very excited for the next release!

  26. TuneInTokyo
    Member
    Posted 2 years ago #

    Works perfectly!!!

    Nice work Chouby!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags