Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

search field wordpress

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
 * Generate custom search form
 *
 * @param string $form Form HTML.
 * @return string Modified form HTML.
 */
function wpdocs_my_search_form( $form ) {
    $form = '<form role="search" method="get" id="searchform" class="searchform" action="' . home_url( '/' ) . '" >
    <div><label class="screen-reader-text" for="s">' . __( 'Search for:' ) . '</label>
    <input type="text" value="' . get_search_query() . '" name="s" id="s" />
    <input type="submit" id="searchsubmit" value="'. esc_attr__( 'Search' ) .'" />
    </div>
    </form>';
 
    return $form;
}
add_filter( 'get_search_form', 'wpdocs_my_search_form' );
Source by developer.wordpress.org #
 
PREVIOUS NEXT
Tagged: #search #field #wordpress
ADD COMMENT
Topic
Name
5+1 =