Hello I am using Enfold with large fixed menu and social icons. Is there a way to add the language switcher flag to the right of the head section?
Hi,
Edit header.php then find this code
do_action('avia_meta_header');
Below, place this code
do_action('icl_language_selector');
Then add this on your custom.css
#lang_sel a {
border: none;
}
#lang_sel {
right: -60px;
top: -10px;
}
#lang_sel a.lang_sel_sel {
background: url(../img/nav-arrow-down.png)right no-repeat;
color: #444;
}
Change the top and right properties to position the switcher.
Cheers,
Ismael
If you just like to embed the flag icons, you may need to follow these steps:
Open functions.php, locate in line 362
add_theme_support( 'avia_post_meta_compat');
Below add:
/*
* F1 add: Language selector (flags) function for header (right menu)
*/
function header_lang_flags(){
$languages = icl_get_languages('skip_missing=0&orderby=code');
if(!empty($languages)){
echo '<ul>';
foreach($languages as $l){
echo '<li>';
if($l['country_flag_url']){
if(!$l['active']) echo '<a href="'.$l['url'].'">';
echo '<img src="'.$l['country_flag_url'].'" alt="'.$l['native_name'].'" title="'.$l['native_name'].'" />';
if(!$l['active']) echo '</a>';
}
echo '</li>';
}
echo '</ul>';
}
}
Then open up header.php, locate on line 113:
do_action('avia_meta_header');
Add below:
header_lang_flags();
Have fun.
Hey!
formateins – thanks for the hint :)
Best regards,
Peter
NP! :)
PS: You should put all your codestuff to an extra file (name it like functions-my.php). Put your functions to it and just add require_once(“functions-my.php”); to the functions.php.
This saves some time, if Kriesi updates the theme. It’s probably easier and quicker than building a child theme. :)