Site logo

Archived topic

Elements depending on language (with WPML)

19 replies · Started by Christoph on May 19, 2020

Viewing posts 16–20 of 20

You can base on this example for your sticky menu logo.

This snippet assumes you're using a Header Element with merged header.

add_filter( 'option_generate_menu_plus_settings', function( $settings ) {
    if ( ICL_LANGUAGE_CODE == 'en' ) {
        $settings['sticky_navigation_logo'] = 'your english logo image URL here';
    } 

    if ( ICL_LANGUAGE_CODE == 'jp' ) {
        $settings['sticky_navigation_logo'] = 'your japanese logo image URL here';
    }
    
    return $settings;
} );

Thank you for your code. It works right.

The logo now changes on the sticky menu as well when switching languages.
Changing the logo on the static and on the sticky menu works in the display mode - desktop.
But only now I noticed that when I check the site display mode - mobile, neither the static logo nor the logo on the sticky menu change when switching the language.

How to make a logo switch for display mode - mobile?

This depends on how you're displaying the logo on mobile.

If you're using the Mobile Header option, you can adjust your function to include its logo:

add_filter( 'option_generate_menu_plus_settings', function( $settings ) {
    if ( ICL_LANGUAGE_CODE == 'en' ) {
        $settings['sticky_navigation_logo'] = 'your english logo image URL here';
        $settings['mobile_header_logo'] = 'your mobile logo';
    } 

    if ( ICL_LANGUAGE_CODE == 'jp' ) {
        $settings['sticky_navigation_logo'] = 'your japanese logo image URL here';
        $settings['mobile_header_logo'] = 'your mobile logo';
    }
    
    return $settings;
} );

Yes. I checked the settings - the mobile header is enabled, added your code - everything works.
Many thanks.

You're welcome :)

This archived topic is closed to new replies.