0
试图找出如何构建以我想要的格式显示的归档页面。我想显示所有帖子,按日期排序。应该看起来像:Wordpress自定义归档格式
February 2010
6 Post-Title
3 Post-Title
January 2010
29 Post-Title
etc...
我很难搞清楚需要创建的循环的细节。我在Wordpress 3.0.4上。
试图找出如何构建以我想要的格式显示的归档页面。我想显示所有帖子,按日期排序。应该看起来像:Wordpress自定义归档格式
February 2010
6 Post-Title
3 Post-Title
January 2010
29 Post-Title
etc...
我很难搞清楚需要创建的循环的细节。我在Wordpress 3.0.4上。
我一旦解决了这个为WP 2.9.something这样的:
是的!我知道:标记的缩进看起来很乱,但如果你仔细观察,它会变得很有意义)
这不是用WP 3.0.x测试过的,但它确实做得非常精确你想要什么。请看看它是否适用于您,并随时询问是否有问题或不合理。
<?php if (have_posts()): ?>
<?php $year = 0; ?>
<?php $month = 0; ?>
<ul>
<?php while (have_posts()): the_post(); ?>
<?php $post_year = substr($post->post_date, 0, 4); ?>
<?php $post_month = substr($post->post_date, 5, 2); ?>
<?php if(($year != $post_year || $month != $post_month) && $year != 0): ?>
</ul>
</li>
<?php endif; ?>
<?php if ($year != $post_year || $month != $post_month): ?>
<li>
<strong><?php the_time('F Y') ?></strong>
<ul>
<?php endif; ?>
<li>
<span><?= mysql2date('j', $post->post_date) ?></span>
<?php the_title() ?>
</li>
<?php $year = $post_year; ?>
<?php $month = $post_month; ?>
<?php endwhile; ?>
</ul>
</li>
</ul>
<?php endif; ?>
这个很漂亮!适用于我的3.0.4安装。谢谢。 – roflwaffle 2011-01-24 16:49:25