如何制作此代码(自定义):
<div id="sb-search" class="sb-search">
<form>
<input class="sb-search-input" placeholder="Search.." type="text" value="" name="search" id="search">
<input class="sb-search-submit" type="submit" value="">
<span class="sb-icon-search"></span>
</form>
</div>
检索这样的搜索结果(wordpress):
<form method="get" class="searchform" action="<?php echo home_url('/'); ?>">
<div>
<input type="text" class="search" name="s" onblur="if(this.value=='')this.value='<?php _e('To search type and hit enter','typegrid'); ?>';" onfocus="if(this.value=='<?php _e('To search type and hit enter','typegrid'); ?>')this.value='';" value="<?php _e('To search type and hit enter','typegrid'); ?>" />
</div>
基本上我得到了这个自定义搜索框的自定义代码,点击幻灯片等。它有一个人们可以键入的字段,但它没有得到我在wordpress网站上使用的结果。我想让它能够从wordpress内容中获得结果,而不会改变div,从而不改变它的设计。请帮忙,我被卡住了!!
答案 0 :(得分:0)
这样就可以了:
<div id="sb-search" class="sb-search">
<form action="<?php echo home_url('/'); ?>">
<input class="sb-search-input" placeholder="Search.." type="text" value="" name="s" id="search">
<input class="sb-search-submit" type="submit" value="">
<span class="sb-icon-search"></span>
</form>
</div>
您只需添加表单操作,并将搜索输入的名称设为“s”。
答案 1 :(得分:0)
<form method="get" class="searchform" action="<?php echo home_url('/'); ?>" >
<input class="sb-search-input" placeholder="Search.." type="text" value="" name="s" id="search">
<input class="sb-search-submit" type="submit" value="">
<span class="sb-icon-search"></span>
</form>
homeurl?s =任何会调用wordpress搜索功能,所以只需要表单的动作GET和ACTION =你的主页