Today we will learn how to Change placeholder text for wordpress search box.
Just Add the below code to the functions.php in your wordpress theme and all done. Placeholder text can be change/Replace to any text also Search button can be change to anything.
function html5_search_form( $form ) { $form = '<section class="search"><form role="search" method="get" id="search-form" action="' . home_url( '/' ) . '" > <label class="screen-reader-text" for="s">' . __('', 'domain') . '</label> <input type="search" value="' . get_search_query() . '" name="s" id="s" placeholder="Search website" /> <input type="submit" id="searchsubmit" value="'. esc_attr__('Go', 'domain') .'" /> </form></section>'; return $form; } add_filter( 'get_search_form', 'html5_search_form' );
it worked. Tks!
Tried this, but it did not work. How old is this article? (It says “05 Dec” but doesn’t say what year.)
Hello Peter,
Its posted on December 5, 2017. sorry to hear its not working, would you like to tell me where you used this code?
Thanks
Hi there, it works fine for me but the button “Go” is misplaced… It appears way above the input…
Thanks for your reply. Would you like to share a screenshot pls.
Ok, is this link works? https://ibb.co/kC7EPx
Any idea ?
Hello Devid,
I have checked its a css issue. for fixing need to add some css.
Ok, I’ll lokk into it.
Thanks.
Welcome, if you stuck knock me. i will fix it
Thanks
this was an awesome help. Thank you
you are the best, and God sent.
Please send me I need another help
I have a members plugin
it creates user
My question is How do I fetch the users from my wordpress database to a front-end table in wordpress.
I can get this done easily in php but in wordpress I am stuck.
Would appreciate if I can learn from your wealth of experience.
Thank You
A search box plugin named “Ivory search”. Can I replaced the search box placeholder using this code..? Please need help. It’s urgent…! I used search box in the top menu bar
hello,
sorry to say this code work for wordpress search only. but could you sent the link so i can check
It worked for me, too.
Thanks a million!
Sound really good…
🙂
this was an awesome help. Thank you
You are Most Welcome
can this code work for a blogger
Hello Haider Jamal,
Sorry to say its will work only for wordpress…
nice sir i will try this
Thanks
What if I want to hide the submit button? Any suggestions?
Hello RICARDO GARCIA DUARTE,
Sorry for lare reply, i was in vacation that why could not reply in time.
You can add this css to your theme. just go to
Appearance->Customize->Additional CSS
#searchsubmit {
display: none !important;
}
Hit on Publish..Done
Let me know if its not work
Thanks
i want to add placeholder in my wordpress search bar , i don’t want to make new search bar using the plugin , i want to change theme placeholder any help please….!
Hello, Hashim Tahir,
you can add wordpress default search bar easily. if you go to widget you can see there are a search widget available. you can use it.
Thanks
Hi, this code works well, thank you! Is there any way that I can only change the search button text? I would like to make it in Danish.
Hello Serhat,
Thanks for your Comment. Of course you can change the button text only with replacing below code
Just Change ‘Go’ text with you desire text.
Knock me if it will work for you.
Thanks