Title: Getting the loop incrementation index (-&gt; if %3)
Last modified: August 21, 2016

---

# Getting the loop incrementation index (-> if %3)

 *  Resolved [nyoz](https://wordpress.org/support/users/nyoz/)
 * (@nyoz)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/getting-the-loop-incrementation-index/)
 * Hi again !
 * I’m continuing my wonderful uses of your plugin, and it’s still as awesome ! 
   🙂
 * I had a quick question though : **is there a way to get the incrementation index
   of the loop ? **
    What I mean by that is that I want to put some code of a field
   value only on the modulo 3 outputs of the loop (so every 3 results). The final
   purpose is to generate a row every 3 items.
 * Is it possible with an [if something] ? Or is it related to the pagination query(
   [http://wordpress.org/support/topic/pagination-133](http://wordpress.org/support/topic/pagination-133))
 * Cheers !
    Regards, – nyoz
 * [https://wordpress.org/plugins/custom-content-shortcode/](https://wordpress.org/plugins/custom-content-shortcode/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/getting-the-loop-incrementation-index/#post-5038687)
 * Hello,
 * I added a few parameters to the [if] shortcode to achieve what you described.
   Please see the latest update.
 * To display something on every 3 results:
 *     ```
       [loop type="post"]
           [content field="title"]
           [if every="3"]
               <hr>
           [/if]
       [/loop]
       ```
   
 * In addition, there’s [if first] and [if last] to display something on the first
   or last post.
 * Hopefully these can be combined to do what you wanted. As I was testing these,
   I realized it’s not so simple to add opening and closing tags around 3 posts 
   at a time, if the total number of posts is not divisible by 3.
 * So, please let me know if it works for you.
 * As for the pagination add-on, it’s taken me longer than planned, but I’m working
   on it. 🙂
 *  Thread Starter [nyoz](https://wordpress.org/support/users/nyoz/)
 * (@nyoz)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/getting-the-loop-incrementation-index/#post-5038690)
 * Works like a charm ! I’m adding a <div class=”clearfix”></div> every 3 items,
   and the global container is declared outside the loop, so there’s no issue if
   the total isn’t %3.
 * Thanks again for your reactivity, amazing ! 🙂
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/getting-the-loop-incrementation-index/#post-5038691)
 * Perfect, I’m glad it worked for your purpose.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Getting the loop incrementation index (-> if %3)’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-content-shortcode_766976.svg)
 * [Custom Content Shortcode](https://wordpress.org/plugins/custom-content-shortcode/)
 * [Support Threads](https://wordpress.org/support/plugin/custom-content-shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-content-shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-content-shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-content-shortcode/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * Last activity: [11 years, 11 months ago](https://wordpress.org/support/topic/getting-the-loop-incrementation-index/#post-5038691)
 * Status: resolved