Archived topic
Change the placeholder text on the seatch box
5 replies · Started by Hasan on May 20, 2019
How can I change the default "Search..." text on the search box to something else like "Search Photo"?
Best regards,
Hasan
Hi there,
you can use the PHP function provided here:
https://docs.generatepress.com/article/generate_navigation_search_output/#add-a-placeholder
Adding PHP:
Added this to the function.php of the child theme, but did not change anything:
add_filter( 'generate_navigation_search_output', function() {
printf(
'<form method="get" class="search-form navigation-search" action="%1$s">
<input type="search" placeholder="Search Photo" class="search-field" value="%2$s" name="s" title="%3$s" />
</form>',
esc_url( home_url( '/' ) ),
esc_attr( get_search_query() ),
esc_attr_x( 'Search', 'label', 'generatepress' )
);
} );
May be because the search bar is not in the navigation?
Ooops - having one of those days.... this link:
https://docs.generatepress.com/article/generate_search_placeholder/
Thanks David! :)
Placed this:
add_filter( 'generate_search_placeholder', function() {
return "Find photo eg: sadarghat, ahsan manzil";
} );
And it worked perfectly!
Perfect - glad to be of help.