Site logo

[Resolved] Site Logo & Title Links to Default Language in Second language Site

Home Forums Support [Resolved] Site Logo & Title Links to Default Language in Second language Site

Home Forums Support Site Logo & Title Links to Default Language in Second language Site

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #2475260
    yitegele

    Hi GP Team!

    How are you?

    I’m using Polylang as the multilingual plugin. My default language is English, and second language is Chinese.

    After you click the Chinese flag and drump to Chinese site, if you click the site logo & title in header, it returns to English site, instead of Chinese site.

    Besides, same problem is NOT happened in the footer’s site logo & site.

    Please help with it. Thank you so much!

    #2475289
    Fernando
    Customer Support

    Hi Yitegele,

    Can you try adding this snippet?:

    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 ( 'Chinese' == pll_current_language( 'name' ) ) {
            return 'URL/cn';
        }
    
        return $url;
    }

    Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets

    Replace Chinese with the Polylang language, and URL with the URL.

    Let’s tackle the footer link afterward. But, can you also try this first?: https://generatepress.com/forums/topic/polylang-navigation-logo-linking/#post-481658

    #2475336
    yitegele

    Hi Fernando,

    Thank you so much!

    It is perfectly working with the site logo. Then the next step is the site title on the header, as the user from the above article only has the problem of site logo, but I both have site logo & title.

    Thank you!

    #2475354
    Fernando
    Customer Support

    Try adding this as well:

    add_filter( 'generate_site_title_href', 'tu_english_navigation_site_title_url' );
    function tu_english_navigation_site_title_url( $url ) {
        if ( ! function_exists( 'pll_current_language' ) ) {
            return $url;
        }
    
        if ( 'Chinese' == pll_current_language( 'name' ) ) {
            return 'URL/cn';
        }
    
        return $url;
    }

    Let us know how it goes.

    #2475402
    yitegele

    Hi Fernando,

    It is perfectly solved! Thank you so much!

    #2475404
    Fernando
    Customer Support

    You’re welcome, Yitegele!

    #2524696
    Sebastien

    Hi GP team,

    I’m having the same issue with a website in english and french.

    The language plugin is Polylang.

    The issue:

    Site is in english by default. When I’m on the French version of the site and click on the header logo, it’s always brings me back to the English version of the site.

    I have tried the code snipped mentioned above by Fernando using the Code Snippets plugin.

    But I can’t seem to get it to work.

    This is the snippet i used:

    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 ( ‘french’ == pll_current_language( ‘name’ ) ) {
    return ‘ https://brigadeweb.com/fr ‘;
    }

    return $url;
    }

    Could you help me fix this?

    Thank you!

    #2524953
    Ying
    Staff
    Customer Support

    Not sure if it’s going to work, but can you try fr instead of french?

    #2524955
    Sebastien

    Hi Ying,

    Unfortunately, it did not work.

    #2524985
    Ying
    Staff
    Customer Support

    How did you add the code?

    #2525002
    Sebastien
    #2525026
    Ying
    Staff
    Customer Support

    Try this code instead:

    add_filter( 'generate_logo_href', 'fr_logo_href' );
    function fr_logo_href( $url ) {
    
    if ( function_exists( 'pll_current_language' ) ) {
      $current_language = pll_current_language();
    }
    if ( 'fr' === $current_language ) {
        $url= 'google.com';
    }
        return $url;
    }
    
    
    #2525038
    Sebastien

    It works!

    You are the best Ying. Thank you!

    #2525076
    Ying
    Staff
    Customer Support

    No problem 🙂

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