Search field displayed twice when added to nav menu


Hello Etienne, To add a search bar in your menu, maybe you could do something like that, a little more straightforward :

    beans_add_smart_action( 'beans_menu[_navbar][_primary]_append_markup', 'myprefix_primary_menu_search' );

    function myprefix_primary_menu_search() {
        ?>
        <li class="tm-search uk-large-visible uk-margin-large-left">
            <?php get_search_form(); ?>
        </li>
        <?php
    }

You can, of course, change the li class as you want. Do some tests. Hope it helps, Have a nice day, Mathieu


Thank you Mathieu,

Your code works perfectly! My problem was that on my local website I didn't select the Primary menu for my nav bar, but on prod it was selected and so with my code I was adding the input twice.

The secret is the [ _ primary ] you added to the call.

Write a reply

Login or register to write a reply, it's free!