If you wish to design a custom language switcher, a function is implemented to help you with all the necessary information. The function that needs to be called is trp_custom_language_switcher().
The function returns an array with the following parameters:
- $custom_ls_array[$language_code][‘language_name’] – the full language name
- $custom_ls_array[$anguage_code][‘language_code’] – the language code of the respective language
- $custom_ls_array[$anguage_code][‘short_language_name’] – the language code of the language, the slug which will be used in the url
- $custom_ls_array[$anguage_code][‘flag_link’] – a link to the flag of the respective language
- $custom_ls_array[$anguage_code][‘current_page_url’] – the URL of the current language with the language slug added
Here is an example of a custom made language switcher:
While here you can see the code snippet:
<?php $array = trp_custom_language_switcher(); ?> <br> <ul> <?php foreach ($array as $name => $item){ ?> <li style="list-style-image: url(<?php echo $item['flag_link'] ?>)"> <a href="<?php echo $item['current_page_url']?>"> <span><?php echo $item['short_language_name']. ':' . $item['language_name']?> </span> </a> </li> <?php }?> </ul> <?php
You can also create a custom language switcher shortcode that you can then use like [[custom-langauge-switcher]]