【发布时间】:2016-06-09 08:02:53
【问题描述】:
我正在使用自定义 WordPress 模板,但我不知道如何在特定位置添加搜索框。当然我的模板包含搜索框,但它在一个奇怪的地方,所以我想添加一个自定义的。我不能通过添加小部件来做到这一点。我必须编辑index.php 才能添加搜索框。
当我添加这个时:
<form method="get" id="searchform" action="<?php bloginfo('home'); ?>/">
<div><input type="text" size="18" value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="s" />
<input type="submit" id="searchsubmit" value="Search" class="btn" />
</div>
</form>
基本上,它正在工作。搜索正常,但搜索框不好看。
那个也可以:
<form method="get" id="search_form" action="<?php bloginfo('home'); ?>"/>
<input type="text" class="text" name="s" value="SEARCH" >
<input type="submit" class="submit" value="" />
</form>
但又一次,它看起来很糟糕。我也必须有自定义 css。
还有一个:
<?php get_search_form(); ?>
效果很好,但同样的问题。就像2000年一样。
我尝试添加自定义 css,但问题是 id 没有在我的网站上搜索任何内容。而是转到http://example.com/?s=WHAT-I-TYPED 它转到http://example.com/
我能用它做什么?
【问题讨论】:
-
theme-> editor ->header.php 把你的自定义代码@audiophonic 或者你可以找到一个插件来做到这一点
-
但自定义 css 显示正常。问题是,当我在每个 custum 搜索框 id 上单击搜索时,根本不会搜索。