前些日子做wordpress cms项目时发现默认wordpress文章列表末项是没有另外个独立的class,这有时会给整合者带来不便。找到了解决的方案,如下:
- <?php while (have_posts()) : the_post(); ?>
- <div <?php post_class() ?>>
- <div class="<?php echo (($i+1 < $wp_query->post_count)?"entry_none":"entry");?>">
- <?php the_content() ?>
- </div>
- </div>
- <?php $i++; ?>
- <?php endwhile; ?>
另外两篇延伸阅读的Wordpress文章:
http://fairyfish.net/2007/07/07/global-variables-and-the-wordpress-loop/
http://fairyfish.net/2008/04/13/define-your-own-wordpress-loop-using-wp_query/
相关日志


试下留言
[回复]