WPML.org Insert Language Selector with ONLY Flags (horizontal)


/ Published in: PHP
Save to your folder(s)

Of course the Plugin from wpml.org has to be installed, the file "wpml-integration.php" from docs/theme-integration has to be copied into your theme-directory and the call include "wpml-integration.php"; has to be copied to your functions.php. After that, you can simply place


Copy this code and paste it in your HTML
  1. // Languages links to display in the header
  2. //
  3. function wpml_languages_list_notext($skip_missing=0, $div_id = "langselector"){
  4. if(function_exists('icl_get_languages')){
  5. $languages = icl_get_languages('skip_missing='.intval($skip_missing));
  6. if(!empty($languages)){
  7. echo '<div id="'.$div_id.'"><ul>';
  8. foreach($languages as $l){
  9. echo '<li>';
  10. if(!$l['active']) echo '<a href="'.$l['url'].'">';
  11. echo '<img src="'.$l['country_flag_url'].'" alt="'.$l['language_code'].'" />';
  12. if(!$l['active']) echo '</a>';
  13. //if(!$l['active']) echo '<a href="'.$l['url'].'">';
  14. // echo $l['native_name'];
  15. //if(!$l['active']) echo ' ('.$l['translated_name'].')';
  16. //if(!$l['active']) echo '</a>';
  17. echo '</li>';
  18. }
  19. echo '</ul></div>';
  20. }
  21. }
  22. }

URL: http://wpml.org/documentation/support/creating-multilingual-wordpress-themes/#language_switcher

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.