Skip to content

Instantly share code, notes, and snippets.

@ckunte
Created April 2, 2015 00:53
Show Gist options
  • Save ckunte/984bbaba668199c1f70f to your computer and use it in GitHub Desktop.
Save ckunte/984bbaba668199c1f70f to your computer and use it in GitHub Desktop.
Search form (for WordPress)
<form method="get" name="srch" action="<?php bloginfo('home'); ?>/">
<div style="margin:10px 0">
<label style="display:inline"><?php _e('Search &rsaquo; '); ?></label>
<input type="text" size="27" value="<?php the_search_query(); ?>" name="s" id="s" />
<input alt="" style="display:none" type="submit" value="search" />
</div>
</form>
@ckunte
Copy link
Author

ckunte commented Apr 2, 2015

For search for focus, use the following code:

<?php if ( is_page('archives') || is_search() || is_404() ) { ?>
 <body onLoad="document.forms.srch.s.focus()">
<?php } else { ?>
 <body>
<?php } ?>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment