wordpress 文章怎样循环数字123

2019年12月23日09:22:28 发表评论 热度193 ℃
  1. <?php if (have_posts()) : ?>
  2. <?php $i=1; while (have_posts()) : the_post(); ?>
  3. <li>
  4. <span class="num"><?php echo $i;$i++; ?></span><?php the_title();//标题 ?>
  5. </li>
  6. <?php endwhile; ?>
  7. <?php else : ?>
  8. <?php endif; ?>

说明:如果$i=0表示从0开始循环,如果$i=1表示从1开始循环,从几都可以,有多少条li就会自动循环到几。

瓜皮猪

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: