WordPress加载搜索表单标签:get_search_form

WordPress模板标签get_search_form用于加载搜索表单,首先会尝试加载模板文件searchform.php,如果该文件不存在,则输出默认的搜索表单HTML。

get_search_form( bool $echo = true )

Table of Contents

函数参数

$echo

布尔值,默认为true,即输出表单内容,如果为false,则只返回结果而不输出。

get_search_form默认输出XHTML版本的标签,如果要输出HTML5版本的标签,需要在主题文件中加入以下代码:

add_theme_support( 'html5', array(
	'search-form',
) );

XHTML版本的输出结果如下:


	

HTML5版本的输出结果如下:


	
	

扩展阅读

get_search_form()函数位于:wp-includes/general-template.php

相关函数:

原创文章,作者:,如若转载,请注明出处:https://ce.771633.xyz/1495.html

Like (0)
Previous 2025年3月8日
Next 2025年3月8日

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注