Very short snippet: Wordpress, improve the search field

In addition to the graphics field input the search of WordPress, you can act on it at the level of code to make it a bit interactive when you click inside it. Easy to achieve an effect lets you insert text into the search field will disappear (and reappear when you leave the field blank) when you click inside it. This technique is comonda as it informs the user of the functionality of the field in question without force us to add a label external that, at times, would steal space to the theme and feel.
This procedure, also, can also be used in other contexts: as a module contacts for example.
The code that I report below, you can insert it in the file searchform.php of your theme.

1
2
3
4
5
6
7
8
'url' ) ; ?> /"> <Form method = "get" id = "SearchForm" action = "<? Php bloginfo ('url');?> /">
<? Php
'Cerca su undolog...' ; // stringa a piacere $ I = 'Search undolog ...', / / string to taste
get_search_query ( ) ; // recupero l'eventuale stringa di una ricerca precedente $ Q = get_search_query () / / get any string of previous research
( $q == "" ) ? $i : $q ; // se non è stata fatta nessuna ricerca imposta la mia stringa $ V = ($ q == "")? $ I: $ q; / / if you have not done any research set my string
?>
?> ':this.value" onfocus="this.value=(this.value == ' <?= $i ?> ')?'':this.value" type="text" value=" <?= $v ?> " name="s" id="s" /> <Input onblur = "this.value = (this.value =='')? '<? = $ I?>': This.value" onfocus = "this.value = (this.value == '<? = $ i?> ')?'': this.value "type =" text "value =" <? = $ v?> "name =" s "id =" s "/>
</ Form>

3 comments to: "Very short snippet: Wordpress, improve the search field"

  1. September 13, 2009 The best of the week # 29 | BigThink :

    [...] Very short snippet: Wordpress, improve the search field enter text into the search field of WordPress that disappears when you click inside it. Enjoyed the article? Rate or No. Ok Thanks a lot! Share tweetmeme_url = ' http://www.bigthink.it/rubriche/il-meglio-della-settimana-29/ ' ; tweetmeme_source = 'Ghido'; Share Tags: best of the week, wordpress [...]

  2. September 16, 2009 Enhance the text fields in Wordpress - FeelTips.com:

    [...] Thanks to Undolog [...]

  3. November 8, 2009 Improving Text Fields in Wordpress' LAB46:

    [...] Also Undolog Share this post! Twitter Delicious Digg Facebook StumbleUpon Google [...]

Leave a comment

TAG XHTML PERMITS: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> INSERTION CODE:
 <pre></pre> // blocco generico <code></code> // blocco generico [cc_actionscript][/cc_actionscript] // Actionscript [cc_actionscript3][/cc_actionscript3] // Actionscript 3 [cc_css][/cc_css] // CSS Style Sheet [cc_html][/cc_html] // HTML [cc_js][/cc_js] // Javascript [cc_objc][/cc_objc] // Objective-C [cc_php][/cc_objc] // PHP [cc_sql][/cc_sql] // SQL 


Stop SOPA