Saya melihat salah satu topik yang cukup menarik dan menantang di Forum Diskusi WPML mengenai hal yang sama dengan judul dari artikel ini. Secara kebetulan, saya baru saja memodifikasi penukar bahasa kostum di footer untuk salah satu dari situs saya yang menggunakan fitur beberapa bahasa, dan juga baru saja menulis artikel yang sama mengenai hal ini beberapa hari yang lalu pada blog saya ini. Terima kasih untuk topik di forum tersebut, sehingga saya dapat melakukan beberapa eksplorasi untuk mengimplementasikan solusi guna menjawab pertanyaan yang telah ditanyakan di forum tadi. Baiklah, berikut ini solusi yang saya buat untuk forum tersebut.
-
Buka berkas functions.php Anda yang biasanya terdapat di direktori utama dari tema yang sedang Anda gunakan, lalu tambahkan kode fungsi berikut:
// In order to display language selector of WPML plugin in footer/header 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="lang_sel_footer">'; // <-- adjust this "lang_sel_footer" with the style that exists in language-selector.css file that belongs to WPML plugin (based on the version you are currently using). 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>'; } }
Karena saya menggunakan WPML versi 1.8.0, maka dalam hal ini saya menggunakan gaya lang_sel_footer yang terdapat di dalam berkas sitepress-multilingual-cms/res/css/language-selector.css ini. Silahkan sesuaikan dengan gaya yang terdapat di berkas .css dari WPML yang sedang Anda gunakan saat ini.
-
Buka berkas header.php yang biasanya terdapat di dalam direktori utama dari tema yang sedang Anda gunakan, lalu tambahkan kode berikut ini:
<link rel="stylesheet" href="<?php echo WP_PLUGIN_URL; ?>/sitepress-multilingual-cms/res/css/language-selector.css" type="text/css" media="all" /> <?php languages_list_footer(); ?>
Sebagai contoh, jika Anda menggunakan tema TwentyTen, maka Anda dapat meletakkan kode di atas tadi setelah baris kode berikut:
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
- Sekarang, segarkan kembali situs Anda, maka seharusnya Anda sudah melihat di bagian paling atas dari halaman situs Anda, penukar bahasa kostum tersebut muncul seperti yang kita inginkan. Jika style dari penukar bahasa tersebut tidak kelihatan bagus di situs Anda, maka permasalahan tersebut biasanya disebabkan oleh style dari penukar bahasa yang digunakan di berkas .css WPML Anda. Silahkan baca dan ikuti kembali langkah pertama di atas dengan teliti.
Selamat menikmati kode yang indah, dan semoga bermanfaat!

Hi there,
I’m afraid I brought myself into trouble here.
Tried to follow your instructions here above.
However, after adding the code in the functions.php, a whole lot of code was shown on top of my website (you can see it if you go there).
So I thought “well, that’s logical, I didn’t finish the proces yet”.
You wrote “Since I used WPML version 1.8.0, then I use lang_sel_footer style that exists in sitepress-multilingual-cms/res/css/language-selector.css file. Please adjust with the style that exists in the related .css file of your WPML.”
I tried to find what you are talking about (I’m not a coder) but couldn’t find it.
So I thought, well let’s go back to the original version. So I deleted the code again in functions.php expecting everything to go back to normal again (with the language switcher at the botton of my page… But I couldn’t anymore. My site was gone, the only thing left was code…
Could you help me out here?
Thanks!
Ferd de Bruijn
Just ftp’d my original function.php to replace the ‘corrupted’ one.
My site is functioning again. But still… I still would like my language switcher on top of my page…
Actually, I’d like to have it as a dropdown in the menu bar… any suggestions?
thanks!!!!!
The same problem here!
FTP savior…
IT’S WORKING!
D Thanks for posting.
I’ve done everything like written above.
Only one thing I can not figure out is changing font color.. I mean languages names font. It’s still black.
I can change background color, frame, but not font..
Please give me some advice
This works! I’m a total newbie, can’t believe I’ve just pulled it off. Thanks again.
Hi there,
Thanks a lot for your solution!!! It works perfectly!!!
I have a question. Is it possible that the language switcher could be displayed without the flags?
I’m not an expert programmer and i’m afraid if i change something in the css the whole thing won’t work anymore.
Much thanks!
@eva polka
If you want to remove the flags, simply replace this code:
with this following:
But I recommend you not to edit that code. Alternatively, simply adjust the setting related to the displayed flags from “WPML” -> “Languages” from your wp-admin, uncheck the “Flags” from “What to include in the language switcher” section.
@Masino Sinaga
Thanks again Masino!
I finally replace the code you give me because in the wpml/ languages the “flags” were already unchecked but the flags in the header were still appearing.
Here’s how it looks now:
http://independentclub.tv/
Thanks again
For Pagelines users, code for function.php need to go in PlatformBase and code for header needs to go in header.php in PlatformPro.
And is working, on the top of the page.
Big tnx for this!