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 does not have Chinese, so I simply write a bit.
Describe
the Get_search_form function is used in WordPress to extract a custom search form or a default search form.
Whether you display a custom form or display a default form depends entirely on the search.php file in your topic.
If the file is present, the file is called automatically, and the default search form is displayed if no.
Use
<?php
get_search_form ($echo = true)
?>
Parameters
$echo Boolean to select whether to display or return a variable.
Default value: True
Instance
It's not as complicated as you think, but it's so simple.
<?php
get_search_form ();
? >
Here's a mention, if you need to integrate Google custom search those words,
You just have to put a custom part of your code in your search.php file, and of course you need to set the style.
Function source Code
<?php/** * Display search form. * 'll attempt to locate the searchform.php file in either the child or * the parent, 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 is primarily used by themes which want to hardcode the search * form into the sidebar and also by the
Search Widget in WordPress. * There is also a action 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 so applies to the Beginn ing 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 don't 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 = ' <form role= ' search ' method= ' get ' id= ' searchform ' action= '. Esc_url (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> ';
if ($echo) echo apply_filters (' Get_search_form ', $form);
else return apply_filters (' Get_search_form ', $form); }?>