PHP functions used to retrieve search forms in WordPress are parsed. wordpressphp_PHP tutorial

Source: Internet
Author: User
Tags search form html
In WordPress, PHP functions used to retrieve search forms are parsed and wordpressphp. In WordPress, the PHP function used to obtain the search form is parsed. in WordPress, the wordpressphpget_search_form function is used to extract the preset search form or default search form. In WordPress, PHP functions used to retrieve search forms are parsed. wordpressphp

The get_search_form function is used in WordPress to extract preset search forms or default search forms. Because the official function does not have any Chinese characters, I simply wrote it.

Description
The get_search_form function is used in WordPress to extract custom search forms or default search forms.
Whether the custom form or default form is displayed depends on whether the search. php file exists in your topic,
If the file exists, the file is called Automatically. if the file does not exist, the default search form is displayed.

Use

<?php  get_search_form($echo = true) ?>

Parameters
$ Echo Boolean type, used to select whether to display or return variables.
Default value: true

Instance
The complexity is not as simple as you think.

<?php  get_search_form(); ?>

If you need to integrate Google custom search,
You just need to put some custom code in your search. php file. of course you need to set the style.

Function Source code

<?php /** * Display search form. * * Will first 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 * will be displayed. The default search form is HTML, which will 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 an action that is called whenever the function is run called, * 'get_search_form'. This can be useful for outputting JavaScript that the * search relies on or various formatting that applies to the beginning of the * search. To give a few examples of what it can be 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);}?>

Articles you may be interested in:
  • Analysis of functions used for title display in WordPress development
  • Use of PHP functions for debugging thumbnails in WordPress
  • Configuration solves the problem of automatically adding a slash to the WordPress path on the Nginx server
  • Use the wp_count_posts function in WordPress to count the number of articles
  • Detailed description of PHP functions that call comment templates and output comments cyclically in WordPress
  • The use of the wp_list_categories function in WordPress
  • WordPress restricts non-administrator users to comment only once after the article
  • Describes the PHP functions used to create and add filters in WordPress.
  • Describes how to use the wp_title () function in WordPress development.

In WordPress, the get_search_form function is used to extract preset search forms or default search forms ....

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.