2012-09-11 62 views
0

正常搜索工作正常,但我需要在wordpress中基于类别进行搜索。 对于例如.. 说我有两个类别命名为'汽车'和'巴士',如果我选择汽车类别,然后搜索应显示结果形式汽车类别,如果我有选择总线类别,然后搜索应显示总线类别的结果。基于WordPress的类别搜索

截至目前我使用此代码

<?php wp_dropdown_categories('show_option_all='.__('All Categories',  'appthemes').'&hierarchical='.get_option('cp_cat_hierarchy').'&hide_empty='.get_option('cp_ cat_hide_empty').'&depth='.get_option('cp_search_depth').'&show_count='.get_option('cp_cat_ count').'&pad_counts='.get_option('cp_cat_count').'&orderby=name&title_li=&use_desc_for_tit le=1&tab_index=2&name=scat&selected='.cp_get_search_catid().'&class=searchbar&taxonomy='.AP P_TAX_CAT); ?> 

此代码正在使用Classipress主题

感谢 Shobhit

回答

0

有几种方法来实现这一目标,你必须更换标准的WordPress使用下面的代码在searchform.php中搜索表单。

这将启用基于类别的搜索。

<form role="search" method="get" id="searchform" action="<?php bloginfo('siteurl'); ?>"> 
<div> 
<label class="screen-reader-text" for="s">Search for:</label> 
<input type="text" value="" name="s" id="s" /> 
in <?php wp_dropdown_categories('show_option_all=All Categories'); ?> 
<input type="submit" id="searchsubmit" value="Search" /> 
</div> 
</form> 
+0

真的是它的工作,非常感谢.... – Shobhit