WordPress主题标签the_search_query用于输出搜索关键词,下面是WordPress函数the_search_query的详细用法。
函数描述:
显示搜索查询的内容。应通过esc_attr()函数确保它是安全的再显示在HTML标签上。
代码示例:
function the_search_query() {
/**
* Filters the contents of the search query variable for display.
*
* @since 2.3.0
*
* @param mixed $search Contents of the search query variable.
*/
echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) );
}
search.php中放置如下代码,该函数不带参数,下面的两种方式输出的结果一致
<?php the_search_query(); ?>
<?php echo esc_html( get_search_query( false ) ); ?>
扩展阅读:
the_search_query函数位于wp-includes/general-template.php文件中。
官方地址:https://developer.wordpress.org/reference/functions/the_search_query/
-
WordPress函数:国际化 _nx 翻译字符串,_n + _xWordPress函数:国际化 _nx 翻译字符串,_n + _x
-
WordPress函数:_n_loop 在 pot 文件中注册字符串WordPress函数:_n_loop 在 pot 文件中注册字符串
-
WordPress函数:国际化 _nx_noop 在 pot 中注册字符串WordPress函数:国际化 _nx_noop 在 pot 中注册字符串
-
WordPress 6.5移除区块样板菜单项的方法WordPress 6.5新增的区块样板菜单项,可将不同区块组合成一个新的区块模板,方便重复使用。
-
WordPress做多语言企业网站近期常用小伙伴问追格小编,有没有计划做双语WordPress企业官网主题。
-
WP Multilang WordPress翻译插件WP Multilang插件的主要功能是提供多语言支持,使用户能够创建多语言版本的网站,满足不同语言用户的需求。
暂无评论,抢个沙发...