我使用自定义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/
我该怎么办?
答案 0 :(得分:1)
解决UGLYNESS问题:只需添加插件&#39;简单自定义css&#39;:minify the CSS。然后编写一些CSS以使它漂亮。
要解决SEARCH问题,请在输入字段中将name="search"
替换为name="s"
(来源:https://nl.wordpress.org/plugins/simple-custom-css/)。