我尝试为WordPress中的自定义帖子类型设置年度(按月分组)存档。但是我的代码没有按方面工作。对于更熟悉 WordPress 和 PHP 但我无法正常工作的人来说,这显然是显而易见的。
下面的代码按月分组,但每个帖子类型都是单独的。也许我需要合并展位。但是怎么做?
<?php query_posts (array ('post_type' => array('images', 'articles')));?>
<?php
if (have_posts()) : while (have_posts()) : the_post();
// save month to a variable
$month = the_date('M', '', '', FALSE);
// If not used before print it
if ($month != $m_check) {
echo "<h2>" . $month . "</h2>";
}
// save month to check variable
$m_check = $month;
?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br/>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query();?>
问候,史蒂夫