Searchform inside list item tags not working when hitting Enter
-
Hi,
I’m currently designing a site (it’s not online, yet, so I can’t link it, sorry) and I came across a rather weird issue concerning the WordPress Searchbox.
Scenario: I have a menu in the topbar of my site and it includes the searchform that I add via the ‘wp_nav_menu_items’ filter.
Here’s my filter function:
function add_search_box_to_menu( $items, $args ){ if( $args->theme_location === 'top-bar-r' ){ return $items . '<li class="drop-down-search-box">' . get_search_form(false) . '</li>'; } return $items; } add_filter( 'wp_nav_menu_items', 'add_search_box_to_menu', 10, 2 );
And here’s my searchbox that is added:
<form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>"> <div class="row collapse"> <?php do_action( 'foundationpress_searchform_top' ); ?> <div class="small-8 columns"> <input type="text" value="" name="s" id="s" placeholder="<?php esc_attr_e( 'Search', 'foundationpress' ); ?>"> </div> <?php do_action( 'foundationpress_searchform_before_search_button' ); ?> <div class="small-4 columns"> <input type="submit" id="searchsubmit" value="?" class="prefix button fa"> </div> <?php do_action( 'foundationpress_searchform_after_search_button' ); ?> </div> </form>
As you can see, I’m using FoundationPress but that’s irrelevant at this point, I think.
The issue I’ve come across here is that the searchbox works perfectly fine when I type my search term and then click the search button.
However, it does not work when I type my search term and then hit the enter key.But that’s not all. When changing the
<li>
tags to, say<div>
tags in the add_search_box_to_menu function, the search via the enter key does work.I have no idea why, and for my layout and consistency purposes throught the menu items I’d like it to work with
<li>
tags.
Has anyone come across this issue, too? Or maybe someone just knows this stuff enough to give me some clues? Because I got none.Thanks in advance!
- The topic ‘Searchform inside list item tags not working when hitting Enter’ is closed to new replies.