Title: Dropdown doesnt work
Last modified: August 21, 2016

---

# Dropdown doesnt work

 *  Resolved [helloimrob](https://wordpress.org/support/users/helloimrob/)
 * (@helloimrob)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/dropdown-doesnt-work-1/)
 * Hi there!
    I’m installing the polylang plugin for a friend right now, but the
   dropdown functionality isn’t working for me :/ If I use it without dropdown its
   working, but he wants to use ~5 languages, so one below the other isn’t working.
 * I’m using the following line in the header:
    `<?php pll_the_languages(array('
   hide_current'=>1,'dropdown'=>1)); ?>`
 * See here:
    [http://shoutkey.com/pliable](http://shoutkey.com/pliable)
 * If would really appreciate some help 🙂
 * Thanks,
    Robert
 * [http://wordpress.org/plugins/polylang/](http://wordpress.org/plugins/polylang/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Chouby](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/dropdown-doesnt-work-1/#post-4545563)
 * Did you read this?
    [http://wordpress.org/support/topic/pll_the_languages-dropdown-doesnt-redirect-when-language-is-selected](http://wordpress.org/support/topic/pll_the_languages-dropdown-doesnt-redirect-when-language-is-selected)
 *  Thread Starter [helloimrob](https://wordpress.org/support/users/helloimrob/)
 * (@helloimrob)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/dropdown-doesnt-work-1/#post-4545641)
 * Hi!
    Thanks for the fast answer and link, didnt read that before.
 * Could you tell me/us which code I have to use to get the dropdown working? Or
   is this too complicated?
    Im new with PHP, so I just included everything regarding
   your in-code comments:
 *     ```
       foreach ($polylang->model->get_languages_list() as $language) {
       				$url = $force_home || ($url = $polylang->links->get_translation_url($language)) == null ? $polylang->links->get_home_url($language) : $url;
       				$urls[] = '"'.esc_js($language->slug).'":"'.esc_url($url).'"';
       			}
   
       			$urls = implode(',', $urls);
   
       			$js = "
       				<script type='text/javascript'>
       					//<![CDATA[
       					var urls = {{$urls}};
       					var d = document.getElementById('lang_choice');
       					d.onchange = function() {
       						for (var i in urls) {
       							if (this.value == i)
       								location.href = urls[i];
       						}
       					}
       					//]]>
       				</script>";
   
       			echo $js;
       ```
   
 * but this (maybe obviously) didn’t worked.
 * Thanks!
 *  Plugin Author [Chouby](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/dropdown-doesnt-work-1/#post-4545650)
 * Try adding the line:
 *     ```
       global $polylang;
       ```
   
 * above your code.
 *  Thread Starter [helloimrob](https://wordpress.org/support/users/helloimrob/)
 * (@helloimrob)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/dropdown-doesnt-work-1/#post-4545651)
 * Hi! Thanks a lot for the fast answer. Added the code. Now no error anymore, but
   it still doesnt work :/
 * see [http://shoutkey.com/sanctuary](http://shoutkey.com/sanctuary)
 *  Plugin Author [Chouby](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/dropdown-doesnt-work-1/#post-4545652)
 * You should output your javascript code after the language switcher, not before.
 *  Thread Starter [helloimrob](https://wordpress.org/support/users/helloimrob/)
 * (@helloimrob)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/dropdown-doesnt-work-1/#post-4545653)
 * thanks a lot Chouby :)!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Dropdown doesnt work’ is closed to new replies.

 * ![](https://ps.w.org/polylang/assets/icon-256x256.png?rev=3433336)
 * [Polylang](https://wordpress.org/plugins/polylang/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/polylang/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/polylang/)
 * [Active Topics](https://wordpress.org/support/plugin/polylang/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/polylang/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/polylang/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [helloimrob](https://wordpress.org/support/users/helloimrob/)
 * Last activity: [12 years, 4 months ago](https://wordpress.org/support/topic/dropdown-doesnt-work-1/#post-4545653)
 * Status: resolved