- This topic has 7 replies, 3 voices, and was last updated 1 year, 7 months ago by Ying.
-
AuthorPosts
-
August 25, 2022 at 7:26 am #2323506Melvin
Hi,
Let’s say I have two Primary menus. One is “English” and the other is “Chinese”.
Currently, I’m using the Conditional Menu plugin to show the menu depending on the pages that are active. But it doesn’t have conditional logo settings.
How do I change the logo URL based on the menu selected?
I want the logo to link to the “English” Homepage (which is currently the default) and the logo to link to the Chinese Menu homepage when “Chinese” is selected.
I hope I didn’t confuse you with my question. 😅
August 25, 2022 at 7:53 am #2323664DavidStaffCustomer SupportHi there,
can you share a link to the site where i can see the different menus ? I can then look to see how we swap logos based on that change
August 25, 2022 at 8:15 am #2323692MelvinHi, David,
Please go to this site. When you click on the logo, it brings you to the default English menu homepage. Now, click on the last link that shows some Chinese characters. You’ll see a page with all the menu links in Chinese characters. Clicking on the logo will bring you back to the English menu home page. I want the logo URL when I’m on the Chinese menu to bring me back to the Chinese menu instead of the English one.
Thanks. 😊
August 25, 2022 at 11:07 am #2323876YingStaffCustomer SupportHi Melvin,
This filter should work on a Chinese language page.
But I checked your site, the pages that are supposed to be Chinese are still in English.
https://www.screencast.com/t/xObTaE7aFuadd_filter( 'generate_logo_href', function() { if (get_bloginfo("language") === 'zh-CN') { return "https://NEW-URL-HERE"; } return home_url( '/' ) ; } );
August 25, 2022 at 2:00 pm #2323974MelvinHi, Ying.
Thanks for the quick response.
Sorry for the noob question. How do I change the <html lang=”en-US”> to <html lang=”zh-CN”>? Do I simply change the texts in the page to Chinese?
August 25, 2022 at 2:38 pm #2323995YingStaffCustomer SupportUsually, when people have more than one language on their sites, they would use a plugin like Polylang to handle it.
But if you don’t think that’s necessary, we can modify the code so it uses page id as the condition, for example:
add_filter( 'generate_logo_href', function() { if (is_page( array( 3, 81, 6 ) ) ) { return "https://NEW-URL-HERE"; } return home_url( '/' ) ; } );
You can replace the
3
,81
,6
with your page ids, you can get the ID in the page editor’s URL.August 25, 2022 at 3:08 pm #2324005MelvinHi, Ying.
It works! Thank you so much! I appreciate you.
Best regards,
Melvin NeoAugust 25, 2022 at 3:36 pm #2324030YingStaffCustomer SupportYou are welcome Melvin 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.