Saya baru saja memodifikasi penukar bahasa kostum untuk salah satu situs yang dilengkapi dengan fitur beberapa bahasa menggunakan plugin WPML dan tema Atahualpa. Saya melihat kode yang terkait untuk mengimplementasikan hal ini melalui artikel berikut: Custom Language Switcher. Sayangnya, sejak WPML telah memperbaharui versinya beberapa kali, fungsi “languages_list_footer()” yang terdapat di artikel tadi seharusnya disesuaikan supaya dapat berjalan sebagaimana mestinya dengan WPML versi terakhir, termasuk mendukung parameter “lang_native_hidden” dan “lang_translated_hidden” yang digunakan oleh fungsi “icl_disp_language”. Baiklah, berikut ini kode modifikasi yang telah saya buat agar hasilnya dapat ditampilkan di bagian bawah (footer) dari tema yang saya gunakan.
// In order to display language selector of WPML plugin in footer of theme function languages_list_footer(){ $languages = icl_get_languages('skip_missing=0&orderby=code'); if($l['icl_lso_native_lang']){ $lang_native_hidden = false; }else{ $lang_native_hidden = true; } if($l['icl_lso_display_lang']){ $lang_translated_hidden = false; }else{ $lang_translated_hidden = true; } if(!empty($languages)){ echo '<div id="footer_language_list">'; foreach($languages as $l){ if($l['country_flag_url']){ echo ' <a href="'.$l['url'].'">'; echo '<img src="'.$l['country_flag_url'].'" height="12" alt="'.$l['language_code'].'" width="18" /> '; if(!$l['active']) echo '</a> '; } echo ' <a href="'.$l['url'].'">'; echo icl_disp_language($l['native_name'], $l['translated_name'],$lang_native_hidden); if(!$l['active']) echo '</a> '; } echo '</div>'; } }
<?php } ?> <?php include (TEMPLATEPATH . '/functions/bfa_meta_tags.php'); ?>
sebelum baris pertama dari kode tadi, tambahkan kode berikut:
<link rel="stylesheet" href="<?php echo WP_PLUGIN_URL; ?>/sitepress-multilingual-cms/res/css/language-selector.css" type="text/css" media="all" />
langkah ini sangat penting, untuk menyertakan berkas .css milik plugin WPML.
<?php languages_list_footer(); ?>
setelah atau di bawah baris kode berikut:
<?php wp_footer(); ?>
<?php do_action("icl_language_selector"); ?> // call the language selector
setelah atau di bawah kode berikut:
<!-- Right Sidebar --> <td id="right">
Agar bisa menampilkan hasil sebagaimana mestinya menggunakan css asli WPML, maka kita harus meletakkan pemanggilan kode css seperti yang ditampilkan di kode atas sebelumnya. Jangan lupa untuk selalu menyertakan pemanggilan berkas .css milik plugin WPML supaya penukar bahasa yang ditampilkan sesuai dengan aslinya.

Thanks for this post.
What is missing from the WPML site is basic instructions for the php noobs. The code you give in point 5 was all I required to put the drop down css language switcher into my site header, but I didnt find it on the wpml site. I spent a good three hours looking for this >:|
The information was qute useful to me, especially after reading the first post. Thanks.
Hi, Masino. Thank you for your post. Could you please advise me: I need to put WPML language switcher (just a few flags without text; this is also a challenge as originally it does not allow remove text leaving just flags) into header and position them correctly (somwhere top right side).
I was able to put this code in header: and it shows up, but I need to reposition them and would like to remove text (currently just made it same color as background, but it`s not very good as size of “switch is too big”. You can see site I`m working on here: http://bwh.silverbulletwebsolutions.com
I`m total noob on coding. Please, please help me. Thank you in advance.
kalau saya lebih suka menggunakan custom page (template), memisah single, archive theme untuk masing-masing kategori, dan custom page untuk halaman depan bahasa inggris. caranya bisa dengan membagi kategori menjadi id dan en, kemudian membuat sub category untuk masing2. contoh ada di web: paradesain.net
web ini sungguh banyak tutorial berharga.