我准备了一个自定义的产品帖子。我想要一个包含少量搜索过滤器的表单。因为我正在寻找第一次。我的产品模板不同,希望在页面或特定div中显示其结果。这怎么可能。我有点困惑。以下是我的表格字段。
<form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
<div class="row">
<div class="col-md-3">Search Keyword:</div>
<div class="col-md-3"><input type="text" placeholder="Search Product..."></div>
<div class="col-md-2"><input type="submit" id="searchsubmit" value="Searchi"></div>
</div>
<div class="row">
<lable for="r1"><input type="radio" name="product-filter" id="r1" checked="chcecked"> Any Words</lable>
<lable for="r2"><input type="radio" name="product-filter" id="r2"> All Words</lable>
<lable for="r3"><input type="radio" name="product-filter" id="r3"> Exact Phrase</lable>
</div>
<em>Search term must be a minimum of 3 characters and a maximum of 20 characters</em>
</form>
答案 0 :(得分:0)
在隐藏的
中传递自定义帖子类型slug喜欢帖子类型名称:产品
<form role="search" method="get" id="searchform" action="<?php echo esc_url( get_permalink(1) ); ?>">
<div class="row">
<div class="col-md-3">Search Keyword:</div>
<div class="col-md-3"><input type="text" placeholder="Search Product..."></div>
<div class="col-md-2"><input type="submit" id="searchsubmit" value="Searchi"> <input type="hidden" name="post_type" value="products"></div>
</div>
<div class="row">
<lable for="r1"><input type="radio" name="product-filter" id="r1" checked="chcecked"> Any Words</lable>
<lable for="r2"><input type="radio" name="product-filter" id="r2"> All Words</lable>
<lable for="r3"><input type="radio" name="product-filter" id="r3"> Exact Phrase</lable>
</div>
<em>Search term must be a minimum of 3 characters and a maximum of 20 characters</em>
</form>
答案 1 :(得分:0)
以下是根据您的指导搜索表单的代码。
1
2
4
5
11
8
9
10
6
7
3
以下是表格
下面的搜索结果<form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
<label>
<span class="screen-reader-text">Search for:</span>
<input type="text" placeholder="Search Product...">
<input type="submit" id="searchsubmit" value="Search">
<input type="hidden" name="post_type" value="product">
</label>
</form>
问题是它总是显示结果。我的自定义帖子名称是'product',没有s。