Detect each 4 using modulus php

前端 未结 2 1789
慢半拍i
慢半拍i 2021-01-22 16:43

I am trying to detect each 4th post to insert extra code in my layout in wordpress using modulus method but I just cant get it.

Here is a short example of mine:

2条回答
  •  醉酒成梦
    2021-01-22 17:30

    You need to start your counter at 1, as you are increasing it at the end of the loop:

    
    

    Either that, or you increase it at the start of the loop / before the check:

    '; } ?>

提交回复
热议问题