Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #703913

    Hi there,
    I would like the WPML language switcher to display only one flag (the language not currently on display)
    It seems to me that showing the flag of the language displayed anyway – is redundant.
    Do you know how I would go about doing that?
    my site is http://www.edoshummus.com

    #703951

    Hi Oren!

    Please consider to contact the WPML Support team, who will be more able to help you with your issues.

    Thanks a lot for your understanding

    Regards,
    Basilis

    #703972

    Hello Basilis,

    As per WPM support suggestion, I added the following script to functions.php in my child theme.

    function custom_languages_menu($items,$args) {
    if (function_exists(‘icl_get_languages’)) {
    $languages = icl_get_languages(‘skip_missing=0’);
    if(1 < count($languages)){
    foreach($languages as $l){
    if(!$l[‘active’]) {
    $items = $items.'<li class=”menu-item-‘.$l[‘language_code’].'”>'.$l['code'].'‘;
    }
    }
    }
    }
    return $items;
    }
    add_filter( ‘wp_nav_menu_items’, ‘custom_languages_menu’,10,2 );

    The result is an error message while loading the site. It seem to indicate that functions.php is not functioning properly.
    as per another issue, you have a user with full admin rights to http://www.edoshummus.com.
    Could you please take a look?

    Thanks a lot

    Oren

    #705029

    Hi Oren!

    It seems like you removed the code already.
    Can you please create a temporary admin login, FTP login and post them here privately? Also, please post the code WPML team provided using – http://pastebin.com/

    Best regards,
    Yigit

    #705057

    Try this

    function my_theme_setup() {
    
        add_filter('wp_list_pages', 'new_nav_menu_items');
    
        add_filter('wp_nav_menu_items', 'new_nav_menu_items');
    
    }
    
    add_action('after_setup_theme', 'my_theme_setup');
    
      
    
    function new_nav_menu_items($items){
    
        if (function_exists('icl_get_languages')){
    
            $languages = icl_get_languages('skip_missing=0');
    
            if (count($languages) > 1){
    
                foreach ($languages as $l) {
    
                    if (!$l['active']) {
    
                        $items .= "<li class='menu-item menu-item-language'>";
    
                        $items .= "<a href='{$l['url']}'>";
    
                        $items .= $l['native_name'];
    
                        $items .= "</a></li>";
    
                    }
    
                }
    
            }
    
        }
    
    return $items;
    
    }
    #705075

    Hello Yigit,

    The URL for WP user (admin) is http://www.edoshummus,com/wp-admin
    credentials of WP and FTP are in private content.

    The script I tried to insert is:
    function custom_languages_menu($items,$args) {
    if (function_exists(‘icl_get_languages’)) {
    $languages = icl_get_languages(‘skip_missing=0’);
    if(1 < count($languages)){
    foreach($languages as $l){
    if(!$l[‘active’]) {
    $items = $items.'<li class=”menu-item-‘.$l[‘language_code’].’”>’.$l[‘code’].’‘;
    }
    }
    }
    }
    return $items;
    }
    add_filter( ‘wp_nav_menu_items’, ‘custom_languages_menu’,10,2 );

    This resulted in a complete lock-up of the installation, even after I removed the script. I had to restore functions.php from backup.

    Thanks a lot

    Oren

    #705079

    Sorry Castellanero,
    This script too appears on top of the page.
    I left it for Yigit to see.

    Best

    Oren

    #705119

    Hey!

    There was a closing PHP tag in the middle of your functions.php file. I removed it and re-installed Enfold parent theme. Please review your website now

    Regards,
    Yigit

    #705306

    Thank you Yigit,
    fubnctions.php indeed seems to work smoothly now.
    However, the script still does not do what it is supposed to do – show only the flag of the alternate language.
    I guess I will pick this up with the WPML team.

    All the best

    Oren

    #705314

    Hi Oren!

    Please do so and let us know if there is anything else we can do to help!

    Best regards,
    Yigit

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