The PHP function used in WordPress to get the search form is parsed

Source: Internet
Author: User
Tags search form html
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.