Custom dropdawn duplication using pll_the_languages function.
-
Ok so I am trying to create a custom dropdown button for language selection, I used the filter t add a button, but for some reason a list of languages appears in 2 places(inside a dropdawn button, which is what i want and and at the beggining of the navbar). Not sure what did i do wrong here. Adding a code snippet for filter which I’m using and a screenshot link, to represent my problem better
add_filter( 'wp_nav_menu_items', 'custom_menu_item', 10, 2 ); function custom_menu_item ( $items, $args ) { if (is_page() && $args->theme_location == 'main-nav') { $items .= '<li class="dropdown">'; $items .= '<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">'; if (function_exists('pll_current_language')){ $items .= pll_current_language('name'); }; $items .= '<span class="caret"></span>'; $items .= '</button>'; $items .= '<ul class="lang-switch dropdown-menu" aria-labelledby="dropdownMenu1">'; if (function_exists('pll_the_languages')){ $items .= pll_the_languages(array('show_flags'=>1,'show_names'=>1)); }; $items .= '</ul>'; $items .= '</li>'; } return $items; }
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
The topic ‘Custom dropdawn duplication using pll_the_languages function.’ is closed to new replies.