Help with Drop-down action
-
I’m trying to use
<?php pll_the_languages(array('dropdown'=>1)); ?>
to display a language switcher drop-down in my theme, and I found the widget’s drop-down action code in polylang/include/widget.php, but I can’t get it to work. The action code kills the whole page. This is how I’m using it:<?php pll_the_languages(array('dropdown'=>1)); ?> <?php foreach ($polylang->get_languages_list() as $language) { $url = $force_home || ($url = $polylang->get_translation_url($language)) == null ? $polylang->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; } ?>
Any help would be greatly appreciated!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Help with Drop-down action’ is closed to new replies.