
-
AuthorPosts
-
January 14, 2014 at 4:08 pm #209494
Hi,
The WPML language switcher options do not work with this theme, whichever changes i make in WPML are not reflected on the site. Either dropdown list or no flags etc.
We are nearing completion of site and want to make it live this week but i cant make the necessary changes, can we get help with this issue ?
thanks
January 14, 2014 at 6:48 pm #209605Hey bluebirdnet!
What type of header are you using? Do you use the social icons? You can manually add the language switcher by editing header.php, find this code on line 103:
if(strpos($headerS,'bottom_nav_header') === false) avia_social_media_icons($social_args);
Below, add this code:
do_action('icl_language_selector');
The switcher should be visible on the upper left corner of the header.
Regards,
IsmaelJanuary 14, 2014 at 7:30 pm #209635Hi Ismael,
I am using the default theme, it has not been modified so using header included.
Yes social icons are enabled.
I have not changed anything, so perhaps you should check your theme again with WPML ?
Thank you for the code, but isnt your theme loading the language switcher automatically? isnt the code already there ?
January 15, 2014 at 8:45 am #209915Hi!
Normally Enfold will display the WPML flags in the top navigation menu. If you want to add the flags to the main menu add following code to the functions.php file (insert it at the very bottom of the file)
if(!function_exists('avia_append_lang_flags')) { //first append search item to main menu add_filter( 'wp_nav_menu_items', 'avia_append_lang_flags', 10, 2 ); function avia_append_lang_flags( $items, $args ) { if ((is_object($args) && $args->theme_location == 'avia')) { global $avia_config; global $sitepress; $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='language_".$lang['language_code']." $currentlang'><a href='".$lang['url']."'>"; $items .= " <span class='language_flag'><img title='".$lang['native_name']."' src='".$lang['country_flag_url']."' /></span>"; $items .= "</a></li>"; } } } return $items; } }
Best regards,
PeterJanuary 15, 2014 at 4:39 pm #210091Thanks for helping out Peter.
I am ok with the language switcher in the top menu, that is best place. Actually i dont want any flags, just display FR | EN instead.
My assumption is that the theme is placing that switcher there and overriding the WPML settings since it has no effect when i make changes.
January 15, 2014 at 9:22 pm #210278Ismael,
you received login info. could you please look into both our problems?
thanks!
Denny
January 16, 2014 at 11:30 am #210621Hey!
Yes, you can overwrite the default theme function though – i.e. insert following code into the functions.php file
if(!function_exists('avia_wpml_language_switch')) { function avia_wpml_language_switch() { global $sitepress; $languages = icl_get_languages('skip_missing=0&orderby=custom'); $output = ""; if(is_array($languages)) { $output .= "<ul class='avia_wpml_language_switch'>"; $last_index = count($languages) - 1; $counter = 0; foreach($languages as $key => $lang) { $separator = ($counter < $last_index) ? ' | ' : ''; $currentlang = (ICL_LANGUAGE_CODE == $lang['language_code']) ? 'avia_current_lang' : ''; if(is_home() || is_front_page()) $lang['url'] = $sitepress->language_url($lang['language_code']); $output .= "<li class='language_".$lang['language_code']." $currentlang'><a href='".$lang['url']."'>"; $output .= " <span class='language_code'>".strtoupper($lang['language_code'])."</span>"; $output .= "</a>$separator</li>"; $counter++; } $output .= "</ul>"; } echo $output; } }
to overwrite the default language switcher code. Then use this css code
.avia_wpml_language_switch li span.language_code{display: block !important;}
to show the language shortcode instead of the flag.
Best regards,
PeterJanuary 17, 2014 at 3:22 am #210977Hi Peter,
thanks for this code! ok i added the code at bottom of functions.php file but no change.
where do i put the css code ?
January 17, 2014 at 7:00 am #211044Hey!
Place it on Quick CSS or custom.css. It is important that you add the css code.
Cheers!
IsmaelJanuary 17, 2014 at 4:38 pm #211259Ismael / Peter
still have the flags, no changes.
tried to add the css code in custom.css maybe i am not putting it at the right place, can you show exactly how the file should look like with code.
i really need to get rid of those flags.
thanks
DennyJanuary 18, 2014 at 6:27 pm #211611Hi!
Please add the code into the functions.php file and post a link to your website.
Best regards,
PeterJanuary 19, 2014 at 3:18 am #211857Peter,
please show me how the css code should look like in the custom.css ?
January 20, 2014 at 10:57 am #212166Hey!
This code should work: https://kriesi.at/support/topic/wpml-language-switcher-options-not-working/#post-210621 – if it doesn’t please post a link to your website.
Best regards,
Peter -
AuthorPosts
- The topic ‘WPML Language switcher options not working’ is closed to new replies.