- This topic has 9 replies, 3 voices, and was last updated 2 years, 11 months ago by David.
-
AuthorPosts
-
April 19, 2021 at 12:56 pm #1740815Kathryn
Hi there,
Currently, search on my website shows only icon and when the icon is clicked, it activates the search functionality. I need complete search box to be displayed (input field with placeholder and search button with icon as “button text”).
My current PHP for search:
function search_filter($query) { if ( !is_admin() && $query->is_main_query() ) { if ($query->is_search) { $query->set('post_type', 'product'); } } } add_action('pre_get_posts','search_filter'); add_filter( 'generate_navigation_search_output', function($output) { $output = sprintf( '<form method="get" class="search-form navigation-search" action="%1$s"> <input type="search" class="search-field" value="%2$s" name="s" title="%2$s"> </form>', esc_url( home_url( '/' ) ), esc_attr_x( 'Search', 'label', 'generatepress' ) ); return $output; } );
April 19, 2021 at 3:38 pm #1740906KathrynThis is slightly modified code. Is it possible to make search box completely visible – input field with placeholder + search button (search icon as button text)?
function search_filter($query) { if ( !is_admin() && $query->is_main_query() ) { if ($query->is_search) { $query->set('post_type', 'product'); } } } add_action('pre_get_posts','search_filter'); add_filter( 'generate_navigation_search_output', function($output) { $output = sprintf( '<form method="get" class="search-form navigation-search" action="%1$s"> <input type="search" placeholder="Search..." class="search-field" value="" name="s" title="%2$s" /> </form>', esc_url( home_url( '/' ) ), esc_attr_x( 'Search', 'label', 'generatepress' ) ); return $output; } );
April 19, 2021 at 10:34 pm #1741119ElvinStaffCustomer SupportHi there,
This is slightly modified code. Is it possible to make search box completely visible – input field with placeholder + search button (search icon as button text)?
It’s definitely possible w/ a few tweaks on the code. But I can’t picture how you want it to look.
Do you have any mockup image of how you want it to be laid out? Do you want to use any specific search icon?
Let us know.
April 20, 2021 at 3:37 am #1741374KathrynI want it to be always visible. I will style the box, just need input field (with placeholder) and search button (search icon as button and when clicked it searches the term) always visible – not only visible on click. So, the most basic search form with the same functionality.
April 20, 2021 at 3:44 am #1741375KathrynOmg man, lifetime package and i need to wait 7 hours only to be asked something like this. Sorry, but this is frustrating.
April 20, 2021 at 4:08 am #1741413DavidStaffCustomer SupportHi there,
sorry if we have caused any frustration – we aim to answer all requests within 24hrs and sometimes we need to ask a few questions to fully understand the requirement.
The simplest solution would be to NOT use the Navigation Search.
Instead you can hook in the wp search form using a function like so:
add_action('generate_menu_bar_items', function() { get_search_form(); });
Or you could use a Hook Element to add the function call.
It will require some CSS to style – which we can help with if you require.
April 20, 2021 at 5:57 am #1741511KathrynThank you. I just need to clear out the search input field once the search has been completed.
April 20, 2021 at 8:12 am #1741984KathrynIs this possible?
April 20, 2021 at 9:15 am #1742048KathrynSolved it, never mind
April 21, 2021 at 12:09 am #1742694DavidStaffCustomer SupportGlad to hear you found the solution.
-
AuthorPosts
- You must be logged in to reply to this topic.