-
AuthorPosts
-
February 3, 2014 at 9:21 am #218673
Hi,
I am looking for a different solution with the WPML Flags on Enfold and I am looking for something like this:
1) No language text needed (i.e. English), just two flags side by side
2) Flags should go ABOVE the last menu item on desktop.
3) On iPhone / responsive, it should show BELOW the drop-down menu
4) Finally, there is a flag that I would like to change the image: sitepress-multilingual-cms/res/flags/ar.png – I know I can easily replace the image directly on that directory, but is there a better Quick CSS way to point that flag to a different image?I’m not sure if these are all easy, but all help one can give is welcome.
Thank you.February 3, 2014 at 10:58 am #218717Hi!
1) 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; } }
2+3) You can try to use a negative margin-top to re-position the flags (i.e. above the main menu links).
4) In the code I posted above replace
if(is_home() || is_front_page()) $lang['url'] = $sitepress->language_url($lang['language_code']);
with
if(is_home() || is_front_page()) $lang['url'] = $sitepress->language_url($lang['language_code']); if(ICL_LANGUAGE_CODE == 'ar') $lang['country_flag_url'] = 'http://my-custom-flag.png';
and instead of http://my-custom-flag.png insert the url to your flag image.
Best regards,
Peter -
AuthorPosts
- The topic ‘WPML tweaks on Enfold’ is closed to new replies.