Archived topic
Polylang - navigation logo linking
10 replies · Started by Adam on January 27, 2018
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 🙂
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 :)
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.
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
Awesome, thanks for the sharing the solution! :)
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!!
Hi there,
Can you start a new topic?
Thanks!
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. :)
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 :)
It worked! I added it using Code Snippets, and now it works perfectly. Thank you very much, Tom! :)
You're welcome :)