WordPress load search form tag: get_ search_ form

WordPress template tag get_ search_ Form is used to load the search form. First, it attempts to load the template file searchform.php If the file does not exist, the default search form HTML will be output.

get_search_form( bool $echo = true )

Function parameters


Boolean value. The default value is true, that is, the form content is output. If it is false, only the result is returned without output.

get_ search_ Form outputs XHTML version tags by default. If you want to output HTML5 version tags, you need to add the following code in the theme file:

add_theme_support( 'html5', array(
) );

The output of XHTML version is as follows:

<form role="search" method="get" id="searchform" class="searchform" action="https://www.beizigen.com/">
		<label class="screen-reader-text" for="s">搜索:</label>
		<input type="text" value="" name="s" id="s" />
		<input type="submit" id="searchsubmit" value="搜索" />

The output of HTML5 is as follows:

<form role="search" method="get" class="search-form" action="https://www.beizigen.com/">
		<span class="screen-reader-text">搜索:</span>
		<input type="search" class="search-field" placeholder="搜索&hellip;" value="" name="s" />
	<input type="submit" class="search-submit" value="搜索" />

Extended reading

get_ search_ The form() function is located in: WP includes / general- template.php

Related Tags:

  • get_ header()
  • get_ sidebar()
  • get_ template_ part()
  • comments_ template()
  • get_ footer()
Related Article
WordPress comment date tag: comment_date

WordPress template tags comment_ Date is used to output the date of a comment, usually in a custom comment template. Read more

WordPress comment summary tag: comment_excerpt

WordPress template tags comment_ Excerpt is used to output the summary of comments. The default output is 20 characters. It Read more

WordPress comment time tag: comment_time

WordPress template tags comment_ Time is used to output the publishing time of the current comment, which is the same Read more

WordPress RSS format comment author name tag: comment_author_rss

WordPress template tags comment_ author_ RSS is used to output the comment author name in RSS format, which has no Read more

Leave a Reply

Your email address will not be published. Required fields are marked *

To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image