The Get_search_form function is used in WordPress to extract a preset search form or a default search form. Because the official this function is not Chinese, so I wrote it briefly.
Describe
The Get_search_form function is used in WordPress to extract custom search forms or default search forms.
Whether the custom form is displayed or the default form is displayed depends entirely on the search.php file in your theme.
If the file is present, the file is called automatically, and if not, the default search form is displayed.
Use
<?php get_search_form ($echo = True)?>
Parameters
$echo Boolean that is used to select whether to display or return variables.
Default value: True
Instance
Not as complicated as you might think, it's really that simple.
<?php get_search_form ();?>
Mention here, if you need to integrate Google custom search for those words,
You just have to put the custom part of the code in your search.php file, and of course you need to set the style.
Function source Code
<?php/** * Display search form. * Would first attempt to locate the searchform.php file in either the child or the parent and then load it. If it doesn ' t exist, then the default search form * would be displayed. The default search form is HTML, which'll be displayed. * There is a filter applied to the search form HTML in order to edit or replace * it. The filter is ' get_search_form '. * * This function was primarily used by themes which want to hardcode the search * form into the sidebar and also by the SE Arch widget in WordPress. * * There is also a action that is called whenever the function is run called, * ' Get_search_form '. This can is useful for outputting JavaScript, the * search relies on or various formatting, applies to the Beginni Ng of the * search. To give a few examples of what it can is used for. * * @since 2.7.0 * @param boolean $echo Default to Echo and not return the form. */function Get_search_form ($echo = True) {do_action (' get_search_form '); $search _fOrm_template = locate_template (' searchform.php '); if ('! = $search _form_template) {require ($search _form_template); return;} $form = "; if ($echo) echo apply_filters (' Get_search_form ', $form); else return apply_filters (' Get_search_form ', $form);}? >
The above describes the WordPress used to get the search form PHP function use analysis, including the aspects of the content, I hope the PHP tutorial interested in a friend helpful.