query_posts
? Может есть элегантный способ реализовать такое? <?php // демо стили
wp_enqueue_style('dashicons'); ?>
<style>
.my-cat li {
float: left;
width: 31%;
text-align: center;
border: 1px solid;
margin: 1%;
list-style: none;
padding: 10px;
}
.my-cat h3 {
border-bottom: 1px solid;
}
.my-cat span {
width: 50%;
float: left;
}
</style>
<?php // сам код вывода
$cat_ids= get_all_category_ids();
foreach ($cat_ids as $cat_id) {
$args = array(
'numberposts' => 3,
'cat' => $cat_id,
'post_status' => 'publish'
);
echo "<h2>" . get_cat_name( $cat_id ) . "</h2>";
echo "<ul class='my-cat cat-" . $cat_id . "'>";
$posts = wp_get_recent_posts($args);
foreach( $posts as $post ){ ?>
<li class="my-post post-<?php echo $post['ID'] ?>">
<h3><a href="<?php echo get_permalink($post['ID']) ?>"><?php echo $post['post_title'] ?></a></h3>
<p><?php echo wp_trim_words($post['post_content'],22) ?></p>
<span class="dashicons dashicons-format-chat"><?php echo $post['comment_count']; ?></span>
<span class="dashicons dashicons-visibility">1777</span>
</li>
<?php }
echo "</ul>";
}
<div class="posts-container">
<div class="posts-column">
<?php
query_posts("category_name=cat1&posts_per_page=3");
if(have_posts()):while(have_posts()):the_post();
?>
<div class="post-item">
/*контент*/
</div>
<?php endwhile; endif; wp_reset_query();?>
</div>
<div class="posts-column">
<?php
query_posts("category_name=cat2&posts_per_page=3");
if(have_posts()):while(have_posts()):the_post();
?>
<div class="post-item">
/*контент*/
</div>
<?php endwhile; endif; wp_reset_query();?>
</div>
<div class="posts-column">
<?php
query_posts("category_name=cat3&posts_per_page=3");
if(have_posts()):while(have_posts()):the_post();
?>
<div class="post-item">
/*контент*/
</div>
<?php endwhile; endif; wp_reset_query();?>
</div>
</div>