欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
Custom Search Form With Wordpress Search Widget | Talk In Code

When adding a search form to your Wordpress blog you will want tohave control over what sort of form is displayed. It is possible tooverride the search form created by the widget function without havingto go into the /wp-includes/widget.php file and editing the wp_widget_search function. Here is the function that is present in Wordpress 2.6.

function wp_widget_search($args) {
 extract($args);
 $searchform_template = get_template_directory() . '/searchform.php';
 
 echo $before_widget;
 
 // Use current theme search form if it exists
 if ( file_exists($searchform_template) ) {
  include_once($searchform_template);
 } else { ?>
  <form id="searchform" method="get" action="<?php bloginfo('url'); ?>/"><div>
  <label class="hidden" for="s"><?php _e('Search for:'); ?></label>
  <input type="text" name="s" id="s" size="15" value="<?php the_search_query(); ?>" />
  <input type="submit" value="<?php echo attribute_escape(__('Search')); ?>" />
  </div></form>
 <?php }
 
 echo $after_widget;
}

Notice that the first thing the function tries to do is load a template file called searchform.php,and if this doesn’t exist the function prints out a standard searchform. That is it basically. If you want to override the search formcreated by this function then just create a file called searchform.php in your template directory and create a search form inside this file. The form must have the following:

  • The action of the form should go to the home of the blog. So if your blog is located at domain.com/blog then the action should go to there.
  • The method of the form should be get, but the form will also work with a post method.
  • A text input box must be present and this must have the name of s.
  • For good search form usability you should print out the search query in the text field of the form. This can be done with the function the_search_query(), which will print out the search query, if there is one.

There are many different ways to create a search form. I found thesetwo in two different templates, created by different people.

<h2>Search</h2>
<form method="get" id="searchform" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<div class="searchbox">
<label for="s">Find:</label>
<input type="text" value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="s" size="14" />
<input type="submit" id="searchsubmit" value="Search" />
</div>
</form>

This one will print out a little bit of JavaScript in the text box.

<div id="search">
<form method="get" id="searchform" action="<?php bloginfo('home'); ?>/">
<div><input type="text" value="search..." name="s" id="s"onfocus="if (this.value == 'search...') {this.value = '';}" onblur="if(this.value == '') {this.value = 'search...';}" />
</div>
</form>
</div>

They both seem to work quite well, but I would advise that anysearch form you create should be copied from the original and modified.This is usually the best practice with Wordpress themes as theWordpress documentation can be a little thin on the ground (or hidden)and their developers tend to use the best functions available.

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
轉:WordPress模板標簽搜索框函數get
WordPress創(chuàng )建搜索頁(yè)面
給 WordPress 博客添加隨機文章的3個(gè)方法【wordpress隨機文章】
打造自己的WordPress側邊欄 | Let''s try Sth. Else!
如何添加 WordPress 2.3 標簽到你使用的主題 | Mylsd's blog
wordpress二次開(kāi)發(fā)技巧之functions.php篇
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久