search_form — Get the site-wide search form.

Search-related functions

Summary

search_form($options = array())

Get the site-wide search form.

Parameters:
  • $options (array) – Valid options are as follows: - show_advanced (bool): whether to show the advanced search; default is false. - submit_value (string): the value of the submit button; default “Submit”. - form_attributes (array): an array containing form tag attributes.
Returns:

string The search form markup.

Usage

Examples

Submit all of the options as an array.

Use the show_advanced boolean to show the advanced search:

<?php echo search_form(array('show_advanced' => true)); ?>

Use the submit_value string to change the text value of the submit button:

<?php echo search_form(array('show_advanced' => true, 'submit_value' => 'I Feel Lucky')); ?>

Use the form_attributes array to add html attributes and ARIA roles to the form element:

<?php echo search_form(array('form_attributes' => array('role' => 'search', 'class' => 'form'))); ?>

See Also