对我个人感兴趣的

想看看有什么有趣的

Valid XHTML 1.0 Transitional Valid CSS!

本站测试通过:Ie6,Ie7,Ie8,Firefox,Safari,Chrome,遨游。
为达到最佳效果,请使用IE6以上的浏览器版本

快速导航

给wordpress文章列表末项加个class

前些日子做wordpress cms项目时发现默认wordpress文章列表末项是没有另外个独立的class,这有时会给整合者带来不便。找到了解决的方案,如下:

  1. <?php while (have_posts()) : the_post(); ?>
  2.         <div <?php post_class() ?>>
  3.             <div class="<?php echo (($i+1 < $wp_query->post_count)?"entry_none":"entry");?>">
  4.                     <?php the_content() ?>
  5.             </div>
  6.         </div>
  7.         <?php $i++; ?>
  8.         <?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/

相关日志

收藏&分享

一条评论 发表在“给wordpress文章列表末项加个class”上

  1. 试下留言

    [回复]

留下回复