How can I make this PHP lines shorter?

前端 未结 4 1500
攒了一身酷
攒了一身酷 2021-01-25 12:45

I have this loop at the same it will count the output:

while ($wp_query->have_posts()) : $wp_query->the_post(); $current++; $current2++;

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-25 13:29

    If I understand what you are asking here, I think you want to alternate your divs with'first' and 'second' classes?

    As such, you can use the % modulo operator (see http://php.net/manual/en/internals2.opcodes.mod.php)

提交回复
热议问题