- This topic has 5 replies, 4 voices, and was last updated 3 years, 11 months ago by Tom.
-
AuthorPosts
-
April 19, 2020 at 2:37 pm #1245869Webmaster
May you please share function / snippet to “always show” search box without having to click the icon? Perhaps remove the icon all together too. I just think it would be great for visitors to have one less click to worry about ๐
<li class="search-item"><a aria-label="Open Search Bar" href="#"></a></li>
If something like this isn’t easily achieved with minimal effort, no worries. I tried searching the site before posting but it’s becoming very hard to use the search box, the displayed data is not always relevant / easy to read. So I did a search query with Duckduckgo and still didn’t have any success.
https://duckduckgo.com/?q=site%3Ageneratepress.com+always+display+search+box
April 20, 2020 at 9:30 am #1246910TomLead DeveloperLead DeveloperHi there,
Wouldn’t this make it so your other menu items couldn’t be clicked? Or would you want the search box to appear below the navigation?
Let me know ๐
April 20, 2020 at 1:19 pm #1247146WebmasterLike this:
You know, I might have better success with just finding out how to add a search box with in GP Hook. https://developer.wordpress.org/reference/functions/get_search_form/
I thought it would make sense to just use what was already there… but maybe not.
April 20, 2020 at 2:50 pm #1247216DavidStaffCustomer SupportHi there,
you can add a search form to the
inside_navigation
hook using this function:add_action( 'generate_inside_navigation','db_navigation_search' ); function db_navigation_search() { ?> <form role="search" method="get" id="searchform" class="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>"> <div> <label class="screen-reader-text" for="s"><?php _x( 'Search for:', 'label' ); ?></label> <input type="text" value="<?php echo get_search_query(); ?>" name="s" id="s" /> <input type="submit" id="searchsubmit" value="<?php echo esc_attr_x( 'Search', 'submit button' ); ?>" /> </div> </form> <?php }
Alternatively you can use a Hook Element and just add the HTML within that function.
Then some CSS to align it to the right of the menu:
.inside-navigation { display: flex; } .inside-navigation form { order: 5; }
April 26, 2020 at 11:27 am #1256777MarcelApril 26, 2020 at 4:10 pm #1256979TomLead DeveloperLead DeveloperAny chance you can link us to your site so we can give you specific CSS?
Thanks!
-
AuthorPosts
- You must be logged in to reply to this topic.