麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 開發 > PHP > 正文

WordPress中用于獲取搜索表單的PHP函數使用解析

2024-05-04 23:41:54
字體:
來源:轉載
供稿:網友
這篇文章主要介紹了WordPress中用于獲取搜索表單的PHP函數使用解析,即get_search_form函數的基本用法,需要的朋友可以參考下
 

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 = '<form role="search" method="get" id="searchform" action="' . esc_url( home_url( '/' ) ) . '" > <div><label class="screen-reader-text" for="s">' . __('Search for:') . '</label> <input type="text" value="' . get_search_query() . '" name="s" id="s" /> <input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" /> </div> </form>';  if ( $echo ) echo apply_filters('get_search_form', $form); else return apply_filters('get_search_form', $form);}?>


注:相關教程知識閱讀請移步到PHP教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 一区二区久久精品66国产精品 | 中文字幕xxx| 中国女警察一级毛片视频 | 免费视频a| 国产精品视频中文字幕 | 免费在线观看亚洲 | 成人一级黄色片 | 成人黄色小视频在线观看 | 久久精品性视频 | 亚洲午夜1000理论片aa | 国产成人在线播放视频 | jizzyouxxxx| 最新中文字幕第一页视频 | 圆产精品久久久久久久久久久 | 国产精品一区二区三区在线看 | 色吧综合网 | 精品一区二区久久久久久久网精 | 亚洲人成在线播放网站 | 免费国产成人高清在线看软件 | 国产精品久久久久久238 | 欧美成人精品欧美一级乱黄 | 羞羞色网站 | 日本黄色大片免费 | 亚洲第一黄色网 | 中文区永久区 | 欧美日韩国产一区二区三区在线观看 | 免费男女视频 | 午夜丰满少妇高清毛片1000部 | 久久久久久久久成人 | 亚洲日本高清 | 国产成人精品无人区一区 | av成人免费看 | 99精品视频在线 | 羞羞的视频在线观看 | 一级成人免费 | 色淫影院 | 日韩精品免费一区二区三区 | 成人毛片在线 | 免费观看国产视频 | 国产在线欧美日韩 | 美女扒开腿让男生桶爽网站 |