2012-09-11 63 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