[Resolved] Conditional Logo URL Help

Home Forums Support [Resolved] Conditional Logo URL Help

Home Forums Support Conditional Logo URL Help

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2323506
    Melvin

    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. 😅

    #2323664
    David
    Staff
    Customer Support

    Hi 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

    #2323692
    Melvin

    Hi, 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. 😊

    #2323876
    Ying
    Staff
    Customer Support

    Hi 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/xObTaE7aFu

    add_filter( 'generate_logo_href', function() {
       if (get_bloginfo("language") === 'zh-CN') {
          return "https://NEW-URL-HERE";
       }
          return home_url( '/' ) ;
    } );
    #2323974
    Melvin

    Hi, 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?

    #2323995
    Ying
    Staff
    Customer Support

    Usually, 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.

    #2324005
    Melvin

    Hi, Ying.

    It works! Thank you so much! I appreciate you.

    Best regards,
    Melvin Neo

    #2324030
    Ying
    Staff
    Customer Support

    You are welcome Melvin 🙂

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