我不知道有没有任何小部件或插件在默认情况下可以做到这一点。要在主题中创建此内容,您需要编写多个查询循环,遍历每个类别,然后使用计数器查询每个类别的最新帖子,以便顶部帖子可以采用不同的样式。
快速示例。
$cats = get_categories();
foreach ( $cats as $cat ) { //Loop through all the categories
$count = 0;
$args = array(
\'cat\' => $cat->term_id, //uses the current category in the loop
\'posts_per_page\' => 4,
\'no_found_rows\' => true, //Performance optimizes the query
\'update_meta_cache\' => false, //We don\'t need post_meta
);
echo \'<div class="aside-\'. $cat->slug .\'">\'. $cat->name .\'</div>\';
$cat_q = new WP_Query( $args );
while( $cat_q->have_posts() ) : $cat_q->the_post();
$count++
if( $count == 1 ) { ?> //Sets the output for the top post
<div id="post-<?php the_ID(); ?>" <?php post_class(\'feature\'); ?>>
<fig><?php the_post_thumbnail(); ?></fig>
<h3 class="post-title feature><a href="<?php the_permalink(); ?>><?php the_title(); ?></a></h3>
<p><?php the_excerpt(); ?></p>
</div>
<div class="right-side">
<ul class="post-list">
<?php } else { ?>
<li><a href="<?php the_permalink(); ?><?php the_title(); ?></a></li>
<?php }
endwhile; ?>
</ul>
</div><!-- /end .right-side -->
</div><!-- /end .aside-<?php echo $cat->slug; ?> -->
<?php } //Ends our category foreach loop