Home  >  Article  >  Backend Development  >  一段显示全一部分类的php代码 想改成显示特定的分类 求帮改下 谢了

一段显示全一部分类的php代码 想改成显示特定的分类 求帮改下 谢了

WBOY
WBOYOriginal
2016-06-13 11:32:01795browse

一段显示全部分类的php代码 想改成显示特定的分类 求帮改下 谢了
add_filter( 'get_terms', 'get_subcategory_terms', 10, 3 );
function get_subcategory_terms( $terms, $taxonomies, $args ) {  
     $new_terms = array(); 
 if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() && is_shop() ) {        
 foreach ( $terms as $key => $term ) {      
       
           $new_terms[] = $term;
            
}       
$terms = $new_terms;   
  }     
  return $terms; 

这段是现在的代码   我数据库里有一个表有一个字段是term_id  我已经把需要显示的分类的term_id存在了$duqu里面  我想问下  怎么把这个变量插到上面的代码里面可以只显示那些被选出来的term_id的分类呢 谢谢了

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn