WordPress中用于获取搜索表单的PHP函数使用解析,wordpressphp_PHP教程
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了WordPress中用于获取搜索表单的PHP函数使用解析,wordpressphp_PHP教程,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2614字,纯文字阅读大概需要4分钟。
内容图文
![WordPress中用于获取搜索表单的PHP函数使用解析,wordpressphp_PHP教程](/upload/InfoBanner/zyjiaocheng/190/9557f9fb8a1a49fd878d0ea265538e66.jpg)
WordPress中用于获取搜索表单的PHP函数使用解析,wordpressphp
get_search_form 函数在 WordPress 中是用来提取预设的搜索表单或者默认的搜索表单的。因为官方这个函数没有中文的,所以我就简单写了一下。
描述
get_search_form 函数在 WordPress 中是用来提取自定义搜索表单或者默认的搜索表单的。
显示自定义表单还是显示默认表单,完全取决于您的主题中是否有search.php文件,
如果有该文件,则自动调用该文件,如果没有则显示默认的搜索表单。
使用
<?php get_search_form($echo = true) ?>
参数
$echo 布尔型,用来选择显示还是返回变量。
默认值:true
实例
没你想象的复杂,其实就是这么简单。
<?php get_search_form(); ?>
这里提一下,如果你需要整合谷歌自定义搜索那些的话,
你只要在你的search.php 文件中将自定义的部分代码放入即可喽,当然你需要设定样式。
函数源代码
<?php /** * Display search form. * * Will first attempt to locate the searchform.php file in either the child or * the parent, then load it. If it doesn't exist, then the default search form * will be displayed. The default search form is HTML, which will be displayed. * There is a filter applied to the search form HTML in order to edit or replace * it. The filter is 'get_search_form'. * * This function is primarily used by themes which want to hardcode the search * form into the sidebar and also by the search widget in WordPress. * * There is also an action that is called whenever the function is run called, * 'get_search_form'. This can be useful for outputting JavaScript that the * search relies on or various formatting that applies to the beginning of the * search. To give a few examples of what it can be used for. * * @since 2.7.0 * @param boolean $echo Default to echo and not return the form. */ function get_search_form($echo = true) { do_action( 'get_search_form' ); $search_form_template = locate_template('searchform.php'); if ( '' != $search_form_template ) { require($search_form_template); return; } $form = ''; if ( $echo ) echo apply_filters('get_search_form', $form); else return apply_filters('get_search_form', $form); } ?>
您可能感兴趣的文章:
- WordPress开发中用于标题显示的相关函数使用解析
- WordPress中调试缩略图的相关PHP函数使用解析
- 配置解决Nginx服务器中WordPress路径不自动加斜杠问题
- 在WordPress中使用wp_count_posts函数来统计文章数量
- 详解WordPress中调用评论模板和循环输出评论的PHP函数
- 详解WordPress中分类函数wp_list_categories的使用
- WordPress中限制非管理员用户在文章后只能评论一次
- 详解WordPress中创建和添加过滤器的相关PHP函数
- 详解WordPress开发中wp_title()函数的用法
http://www.bkjia.com/PHPjc/1088777.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1088777.htmlTechArticleWordPress中用于获取搜索表单的PHP函数使用解析,wordpressphp get_search_form 函数在 WordPress 中是用来提取预设的搜索表单或者默认的搜索表单的。...
内容总结
以上是互联网集市为您收集整理的WordPress中用于获取搜索表单的PHP函数使用解析,wordpressphp_PHP教程全部内容,希望文章能够帮你解决WordPress中用于获取搜索表单的PHP函数使用解析,wordpressphp_PHP教程所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。