The form in your HTML code looks like this:
<form method="get" id="searchform" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<label class="hidden" for="s"><?php _e('Search this site:'); ?></label>
<input type="text" value="Search site" name="s" id="s" />
<input type="submit" id="searchsubmit" value="Search" />
</form>
PHp is not parsed in this fragment, so I guess you didn’t include a PHP file, just regular HTML. Put the search form code in a PHP file.
You could for example add a function like this to your functions.php
:
function t5_search_form( $args = array () )
{
$defaults = array (
'form_id' => 'searchform',
'name' => 's',
'charset' => get_bloginfo( 'charset' ),
'label' => esc_attr__( 'Search', 't5_theme' ),
'action' => site_url(),
'value' => esc_attr(
apply_filters( 'the_search_query', get_search_query( FALSE ) )
),
'submit' => esc_attr__( 'Search', 't5_theme' ),
'template' => '
<form role="search" id="%1$s" accept-charset="%2$s" action="%8$s">
<label for="%3$s">%4$s</label>
<input type="search" name="%3$s" id="%3$s" value="%5$s" aria-required="true" required%6$s>
<input type="submit" value="%7$s">
</form>',
'print' => TRUE
);
$options = array_merge( $defaults, $args );
$options = apply_filters( 't5_searchform', $options );
extract( $options );
$autofocus = ( is_search() and 0 === (int) $GLOBALS["wp_query"]->found_posts )
? ' autofocus' : '';
$form = sprintf(
$template,
$form_id,
$charset,
$name,
$label,
$value,
$autofocus,
$submit,
$action
);
$print and print $form;
return $form;
}
⦠and call that function wherever you need it with t5_search_form();
.
Also, don’t use $_SERVER['PHP_SELF'];
, use echo home_url();
instead.