Archived topic
search placeholder title and previous search dropdown
3 replies · Started by Marijana on October 14, 2020
Hey there!
Hope that you guys could help me with this one.
I have a basic knowledge so the solution is maybe obvious but not to me.
1. I would like the title Search to be shown in a search field placeholder after clicking on it.
2. And second, is it possible to stop displaying suggestions for search in a dropdown after clicking on a search bar. Or how can I change it position to center?
Thanks
Hi there,
1. you can add a placeholder using the PHP snippet provided here:
https://docs.generatepress.com/article/generate_navigation_search_output/#add-a-placeholder
2. I don't think thats possible as i believe its related to the browser.
I still don't see the text inside the search placeholder in navigation bar.
But it looks good in the search widget https://prnt.sc/uzf3uj
Can you suggest more options or a css? I want it to be white.
Thanks!
Hi,
You can try this out PHP snippet out.
add_filter( 'generate_navigation_search_output', function() {
printf(
'<form method="get" class="search-form navigation-search" action="%1$s">
<input type="search" placeholder="%3$s" class="search-field" value="%2$s" name="s" autocomplete="off" title="%3$s" />
</form>',
esc_url( home_url( '/' ) ),
esc_attr( get_search_query() ),
esc_attr_x( 'Search', 'label', 'generatepress' )
);
} );
This adds the "Search" text as placeholder.
As for question 2: I've added autocomplete="off" as a workaround.
Let us know if it works for you.