[Resolved] Polylang – navigation logo linking

Home Forums Support [Resolved] Polylang – navigation logo linking

Home Forums Support Polylang – navigation logo linking

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #481416
    Adam

    I create a website in 2 languages (Polish and English) using Polylang Plugin. I have added the logo to Primary Navigation but the logo link redirects to the same – polish frontpage in both language versions. As I am on the English site, it does not direct me to the frontpage in English but to Polish. I do not know if I can use any of the GPhooks filters? Or any other idea?
    Hope you can help me out 🙂

    #481501
    Tom
    Lead Developer
    Lead Developer

    Hi Adam,

    I wonder if a function like this might help:

    add_filter( 'generate_logo_href', 'tu_english_navigation_logo_url' );
    function tu_english_navigation_logo_url( $url ) {
        if ( ! function_exists( 'pll_current_language' ) ) {
            return $url;
        }
    
        if ( 'English' == pll_current_language( 'name' ) ) {
            return 'URL TO ENGLISH HOMEPAGE';
        }
    
        return $url;
    }

    Let me know 🙂

    #481614
    Adam

    Hi Tom,
    Thank you for your answer.
    I understand that I am going to paste this code into GP Hooks by changing only the URL TO ENGLISH HOMEPAGE. I did this and I marked Execute PHP. I tried in many fields of GP Hooks. The problem has not been solved.

    #481658
    Adam

    I found a solution!
    It was easier than I thought. The problem was not in Theme but in Polylang settings.
    Solution:
    1. Go to WP Dashboard ‘Languages’ -> ‘Settings’ -> ‘URL modifications’
    2. The ‘Hide URL language information for default language’ section must be unchecked -> ‘Save Changes’
    I work as it should!
    Maybe it will be useful to someone.

    Thank you and best regards

    #481855
    Tom
    Lead Developer
    Lead Developer

    Awesome, thanks for the sharing the solution! 🙂

    #514172
    alzate1985

    Hi guys, enjoying your theme a lot. I wonder if you can help me disabling the link of the nav menu logo. On the other hand, I need to know where or how to change the link of the image, in case I need to link somewhere else.

    Thanks so much!!

    #514274
    Leo
    Staff
    Customer Support

    Hi there,

    Can you start a new topic?

    Thanks!

    #1015756
    Leo

    Hi!

    I’m having the same issue with the logo link for different languages using Polylang. Unfortunately, I cannot use the easy solution posted by Adam, so I tried the function suggested by Tom. 

    I made a GP Element like this:

    add_filter( ‘generate_logo_href’, ‘tu_english_navigation_logo_url’ );
    function tu_english_navigation_logo_url( $url ) {
        if ( ! function_exists( ‘pll_current_language’ ) ) {
            return $url;
        }

        if ( ‘English’ == pll_current_language( ‘name’ ) ) {
            return ‘https://www.ruskus-patruskus.com/en/’;
        }

        return $url;
    }

    I placed it “before_logo” (I tried other locations but it doesn’t work and the code lines shows up on the pages). I marked “Execute PHP” and in Display Rules > Location I chose “Entire Site”.

    However, it’s not working. What am I doing wrong?

    Thanks in advance. 🙂

    #1016024
    Tom
    Lead Developer
    Lead Developer

    Instead of adding it as an Element, add it using one of these methods: https://docs.generatepress.com/article/adding-php/

    Let me know if you need more info 🙂

    #1016599
    Leo

    It worked! I added it using Code Snippets, and now it works perfectly. Thank you very much, Tom! 🙂

    #1016912
    Tom
    Lead Developer
    Lead Developer

    You’re welcome 🙂

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.