WordPress输出搜索关键词标签:the_search_query

文 / @WordPress主题

WordPress模板标签the_search_query用于输出搜索关键词,通常用在搜索表单和搜索结果页中。

the_search_query()

该函数没有任何参数,直接调用即可。

函数使用示例

<form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
	<div>
		<input type="text" value="<?php the_search_query(); ?>" name="s" id="s" />
		<input type="submit" id="searchsubmit" value="Search" />
	</div>
</form>

扩展阅读

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

相关函数:

  • get_search_query()
添加UTHEME为好友
扫码添加UTHEME微信为好友
· 分享WordPress相关技术文章,主题上新与优惠动态早知道。
· 微信端最大WordPress社群,限时免费入群。