3

I want to remove "Search for" text from search form in TwentyTwelve, to wrap in in a div for styling, and probably to play with php a bit – and I'd appreciate some advice on how to do that best.

My "sub-questions within a question":

1) Where is the main search function is located?

2) Should I create a separate custom file, add code to functions.php - or is it okay in this case to just edit the original search function?

Thank you in advance for your help!

  • That text is in search.php for the theme, no? If you don't want changes getting lost, look into child themes. – t31os Apr 30 '13 at 18:41
  • Actually, @t31os, that text is not in search.php. That file controls the search results, and I'm looking for ways to modify the search form. Would appreciate more advice from you! – Astoria Apr 30 '13 at 18:43
  • s_ha_dum has you covered, see get_search_form. – t31os Apr 30 '13 at 19:33
6

Modify the searchform.php, or create one in a child theme (recommended), and you should be able to modify the form all you want.

This is the file that get_search_form looks for and is the file used by the default search widget, though it is not listed in the Template Hierarchy.

Reference:

http://codex.wordpress.org/Function_Reference/get_search_form

  • Thank you, @s_ha_dum. You're saying "modify search form.php" – but where is that form? I can't find it anywhere. The codex says, If you don't have searchform.php in your Theme, WordPress will render its built-in search form. Could you tell me where is that code that generates the default form? – Astoria Apr 30 '13 at 19:24
  • If there is no file named searchform.php in your theme then create one. The default HTML is in /wp-includes/general-template.php, to which I have already linked, but don't edit that. It is a Core file. Copy the markup into your searchform.php if you need a place to start. – s_ha_dum Apr 30 '13 at 19:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.