-
AuthorPosts
-
January 5, 2016 at 4:20 pm #559995
Hello,
I use the code below to change the behaviour from flags to language ISO code, it works fine in the primary menu. But now I would like to change it to the secondary menu at the right top. If I enable the secondary menu in the Enfold theme options, the flags appear in the secondary menu but the code below seems to be ignored. Changing “main_menu” to “secondary_menu” does not seem to solve the issue. Please help, thanks :o)
/* * WPML language code in navigation bar */ if(!function_exists('avia_append_lang_flags')) { //first append search item to main menu add_filter( 'wp_nav_menu_items', 'avia_append_lang_flags', 20, 2 ); add_filter( 'avf_fallback_menu_items', 'avia_append_lang_flags', 20, 2 ); function avia_append_lang_flags( $items, $args ) { if ((is_object($args) && $args->theme_location == 'avia')) { global $avia_config, $sitepress; if(empty($avia_config['wpml_language_menu_position'])) $avia_config['wpml_language_menu_position'] = apply_filters('avf_wpml_language_switcher_position', 'main_menu'); if($avia_config['wpml_language_menu_position'] != 'main_menu') return $items; $languages = icl_get_languages('skip_missing=0&orderby=custom'); if(is_array($languages)) { foreach($languages as $lang) { $currentlang = (ICL_LANGUAGE_CODE == $lang['language_code']) ? 'avia_current_lang' : ''; if(is_home() || is_front_page()) $lang['url'] = $sitepress->language_url($lang['language_code']); $items .= "<li class='av-language-switch-item language_".$lang['language_code']." $currentlang'><a href='".$lang['url']."'>"; $items .= " " .strtoupper($lang['language_code']). ""; $items .= "</a></li>"; } } } return $items; } } /* * End of WPML language code in navigation bar */
January 6, 2016 at 5:11 pm #560631Hey Jurgen!
not sure what you are trying to achieve. Can you show us an example of the result please? you might want to ask WPML support about this as well, as they know their plugin best.
Best regards,
AndyJanuary 11, 2016 at 2:21 pm #563143Hello,
This code is used on another customers website, in the primary menu and works fine:
http://s13.postimg.org/ovz62bpfb/primary_ok.pngNow I am trying to achieve the same result, but in the secondary menu above and it doesn’t do a thing:
http://s21.postimg.org/c66tvh93r/secondary_nok.pngMay be it has something to do with the “main-menu”?
Thanks for helping me out on this!Best regards,
JurgenJanuary 12, 2016 at 7:44 am #563717January 12, 2016 at 9:40 am #563763Hey!
Thanks a lot for pointing us out the solution, based on WPML support.
Please do let us know if we can do anything else for you, we will be more than happy to help!Cheers!
Basilis -
AuthorPosts
- The topic ‘WPML Language codes in secondary menu’ is closed to new replies.