假设每个帖子只有一个子类别,那么:
$parent_category_id = 12;
<?php query_posts(\'category_name=group&posts_per_page=10\'); ?>
<?php if (have_posts()) : $counter = 0; ?>
<?php while (have_posts()) : the_post(); ?>
<div <?php if($wp_query->current_post % 2 == 0) post_class(\'clearfix\'); else post_class(\'clearfix last\'); ?>>
<?php the_post_thumbnail(\'thumbnail\'); ?>
<?php
$post_categories = wp_get_post_categories( $post_id );
$cats = \'\';
foreach($post_categories as $c){
$cat = get_category($c);
if ($cat->category_parent = $parent_category_id){
$cats = $cat->name;
}
}?>
<span class="title"><em><?php echo $cats; ?></em></span>
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( \'Permalink to %s\', \'twentyten\' ), the_title_attribute( \'echo=0\' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
</div>
<?php $counter++; endwhile; ?>
<?php endif; ?>
只需更新“$parent\\u category\\u id=12;”具有组类别的真实ID。