Of course, that’s easy π Just prepare 3 png pictures with filename corresponding to your language slugs (e.g: en.png, fr.png, de.png) and put theme in the images directory of your theme folder. Then you can add this code in your function.php:
add_action('sublanguage_custom_switch', 'my_custom_switch', 10, 2);
function my_custom_switch($languages, $sublanguage) {
?>
<ul>
<?php foreach ($languages as $language) { ?>
<li class="<?php echo $language->post_name; ?> <?php if ($sublanguage->current_language->ID == $language->ID) echo 'current'; ?>">
<a href="<?php echo $sublanguage->get_translation_link($language); ?>">
<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/<?php echo $language->post_name; ?>.png" alt="" width="" height="" />
</a>
</li>
<?php } ?>
</ul>
<?php
}
Cool! Works like a charm π
Thank you!!!
Hi, It’s not working for me T^T, I have on the menu one language and inside of him another language:
language
language
And the html code is:
<div class="menu">
<ul id="menu" class="nav tc-hover-menu">
<li class="sublanguage active_language ... menu-item-1025">
<a data-test="joie" href="website">ES <strong class="caret"></strong>
</a>
<ul class="dropdown-menu" style="left: -95.375px;">
<li class="sublanguage ... menu-item-1026">
<a href="website in english">EN</a>
</li>
</ul>
</li>
</ul>
</div>
And my theme is Customizr, and the path of images is:/wp/wp-content/themes/customizr/inc/assets/img
-
This reply was modified 9 years, 8 months ago by
Laura.
-
This reply was modified 9 years, 8 months ago by
Laura.
-
This reply was modified 9 years, 8 months ago by
Laura.
Hello,
Sorry but the solution I gave only work when the language switch is custom or in a widget, but not inside menu. I’ll try to improve this in the future.