Tag: query_posts
获取某个分类下所有文章相关的标签
获取某个分类(Category)下所有文章相关的标签(TAGS) 首先获取分类下的所有文章: query_posts(array( ‘post_type’ => ‘portfolio’, ‘showposts’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => ‘portfolio-class’, ‘terms’ => $the_taxonomy, ‘field’ => ‘term_id’, ) ), ‘orderby’ => ‘date’, ‘order’ => ‘DESC’ ) ); 去过所有posts对象: $portfolio_vars = $wp_query->posts; 这样就可以获取到每个文章的 ID $portfolio_var->ID; 可以通过这个ID 获取到每个文章相关的标签:wp_get_post_terms($portfolio_var->ID, $taxonomy); 然后就可以循环取出各个标题的属性,存储到新的$relate_terms数组里 $portfolio_vars = $wp_query->posts; foreach($portfolio_vars as $portfolio_var){ //$portfolio_ids[] = $portfolio_var->ID; $term_list = wp_get_post_terms($portfolio_var->ID,…