0
搜索插件,我使用WordPress的中,(Relavenssi),允许用户添加quotes
搜索条件,以搜索短语,如“搜索短语”。搜索过滤器精确匹配
我该如何编码,以便当用户选择一个名为“精确匹配”的收音机/复选框时,quotes
会自动添加到搜索查询中,而不是被用户添加到搜索框中?
任何帮助非常感谢,S.
搜索表单下面的代码:
<form action="<?php bloginfo('home'); ?>/" method="post">
<div class="search-icon">
<label for="search" accesskey="4" class="hidden">Search the site</label>
<input type="text" name="s" id="search" value="Enter search term" onblur="this.value = this.value || this.defaultValue;" onfocus="this.value = '';" />
<input type="submit" name="submit" value="GO" class="s-btn" />
<p><a href="#" id="search-anchor">Search Options</a></p>
<div class="option-slide">
<input type="radio" name="sentence" value="" checked="checked" /><label>All Words</label><br />
<input type="radio" name="sentence" value="???" /><label>Exact Match</label>
</div>
</div>
</form>
编辑:基于从下面@Tristar网页设计的答案,我现在已经增加低于这个PHP代码我的搜索表单,尽管它不能正常工作。它回声良好,但不会传回查询。如何将更新后的搜索查询传递给Wordpress?
if(isset($_POST['s']) && $_POST['sentence'] == 'exact') {
$_POST['s'] = '"'.get_search_query().'"';
echo $_POST['s'];
} else {
echo "2";
}
感谢。已经尝试了两种方式,但只能让PHP稍微工作 - 请参阅编辑的问题。 – ss888 2011-05-13 16:49:42
检查上面的编辑,让我知道,如果它可以帮助你。 – 2011-05-16 09:07:25
非常感谢!奇迹般有效! – ss888 2011-05-16 09:49:43