【发布时间】:2013-09-27 12:02:07
【问题描述】:
我想在一个页面上显示所有 Wordpress 帖子,并让结果显示如下:
9 月(当月)的帖子
1- 第一篇文章 2-秒发帖 3- 第三个帖子
下个月的帖子
2- 第一篇文章 2-秒发帖 3- 第三个帖子
我已经完成了这个结果来显示按月排序的所有帖子,但我无法对它们进行分组并将帖子显示为每个月的一个组:
<?php
$month = date('M');
$arrgs = array('orderby' => $month);
$myposts = get_posts($arrgs);
foreach($myposts as $post) :
setup_postdata($post);
?>
<div class="post-item">
<div class="post-info">
<h2 class="post-title">
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>">
<?php the_title(); ?>
</a>
</h2>
<p class="post-meta">Posted by <?php the_author(); ?> Published in <strong><?php echo $month; ?></strong></p>
</div>
</div>
<?php endforeach; wp_reset_postdata(); ?>
【问题讨论】: