WordPress函数The_search_query输出搜索关键词
几乎WordPress网站都带有站内搜索的功能,我们如何在搜索结果页中显示搜索关键词呢?the_search_query函数能帮我们输出搜索关键词,下面是WordPress函数the_search_query的详细用法。 几乎WordPress网站都带有站内搜索的功能,我们如何在搜索结果页中显示搜索关键词呢?the_search_query函数能帮我们输出搜索关键词,下面是WordPress函数the_search_query的详细用法。 函数描述 显示搜索查询的内容。应通过esc_attr()函数确保它是安全的再显示在HTML标签上。 函数原型 the_search_query函数位于wp-includes/general-template.php文件中,下面是它的源代码,官方在线地址:https://developer.wordpress.org/reference/functions/the_search_query/ 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 ) ) );...