- This topic has 13 replies, 4 voices, and was last updated 3 years, 3 months ago by
Ying.
-
AuthorPosts
-
December 27, 2022 at 8:20 pm #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!
December 27, 2022 at 9:12 pm #2475289Fernando 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
December 27, 2022 at 10:43 pm #2475336yitegele
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!
December 27, 2022 at 11:19 pm #2475354Fernando 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.
December 28, 2022 at 12:31 am #2475402yitegele
Hi Fernando,
It is perfectly solved! Thank you so much!
December 28, 2022 at 12:33 am #2475404Fernando Customer Support
You’re welcome, Yitegele!
February 7, 2023 at 8:05 am #2524696Sebastien
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!
February 7, 2023 at 11:25 am #2524953Ying
StaffCustomer SupportNot sure if it’s going to work, but can you try
frinstead offrench?February 7, 2023 at 11:27 am #2524955Sebastien
Hi Ying,
Unfortunately, it did not work.
February 7, 2023 at 11:52 am #2524985Ying
StaffCustomer SupportHow did you add the code?
February 7, 2023 at 12:10 pm #2525002Sebastien
Using the Code Snippets plugin.
Like this:
https://drive.google.com/file/d/1p2Jebxu58Heequ-aZJWu6-j5vxk0DqpE/view?usp=share_link
February 7, 2023 at 12:32 pm #2525026Ying
StaffCustomer SupportTry 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; }February 7, 2023 at 12:44 pm #2525038Sebastien
It works!
You are the best Ying. Thank you!
February 7, 2023 at 1:25 pm #2525076Ying
StaffCustomer SupportNo problem 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.