Modifying the default search widget

You can hook into the ‘get_search_form’ action hook ( check out the “last option” part of the link below ). Set the priority high enough to override anything created in a theme.

A plugin could look like ( from the link below ):

function my_search_form( $form ) {
    $form = '<form role="search" method="get" id="searchform" class="searchform" action="' . home_url( "https://wordpress.stackexchange.com/" ) . '" >
    <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', 'my_search_form', 100 );

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

Leave a Comment