Skip to content

Instantly share code, notes, and snippets.

@joedolson
Created March 6, 2022 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joedolson/7d7a02b86d218afe8b63e37450dadfba to your computer and use it in GitHub Desktop.
Save joedolson/7d7a02b86d218afe8b63e37450dadfba to your computer and use it in GitHub Desktop.
<form role="search" method="get" class="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<?php
$rand = '_' . mt_rand( 10000, 99999 );
?>
<label for="search<?php echo $rand; ?>"><?php echo _x( 'Search for:', 'label', 'textdomain' ); ?></label>
<input id="search<?php echo $rand; ?>" type="search" class="search-field" value="<?php echo get_search_query(); ?>" name="s" />
<button type="submit" class="search-submit"><?php echo _x( 'Search', 'submit button', 'textdomain' ); ?></button>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment