Title: Insert code after every x posts?
Last modified: August 31, 2016

---

# Insert code after every x posts?

 *  Resolved Anonymous User 1789484
 * (@anonymized-1789484)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/insert-code-after-every-x-posts/)
 * Wondering if there is a method to insert a snippet of code (ad implementation)
   after every new page load? Currently calling 14 posts and would like to insert
   the same ad post after the 14 and before the next lot of 14 are loaded.
 * [https://wordpress.org/plugins/ajax-load-more/](https://wordpress.org/plugins/ajax-load-more/)

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

 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/insert-code-after-every-x-posts/#post-7268280)
 * Hi shakingpaper,
    Have you tried adding it directly to your repeater tmeplate?
 *     ```
       <li>
       <h3><?php the _title(); ?></h3>
       </li>
       <?php
         if($alm_current === 14){
           // Do stuff
         }
       ?>
       ```
   
 *  Thread Starter Anonymous User 1789484
 * (@anonymized-1789484)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/insert-code-after-every-x-posts/#post-7268315)
 * Thanks dcooney!
 * I didn’t realise you could add alm conditionals in. That’s perfect.
 *  [mikataghara](https://wordpress.org/support/users/mikataghara/)
 * (@mikataghara)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/insert-code-after-every-x-posts/#post-7268627)
 * hi dcooney, i have similiar problem with shaking paper. but i dont know how to
   insert this code. i put it after deafult template code.
 * <li<?php if (! has_post_thumbnail() ) { echo ‘ class=”no-img”‘; } ?>>
    <?php 
   if ( has_post_thumbnail() ) { the_post_thumbnail(array(150,150)); }?> <h3>” title
   =”<?php the_title(); ?>”><?php the_title(); ?></h3> <p class=”entry-meta”> <?
   php the_time(“F d, Y”); ?> </p> <?php the_excerpt(); ?>
    -  <h3><?php the _title(); ?></h3>
    - <?php
       if($alm_current === 5){ <img src=”[http://www.mysite.com/blablabla.jpg&#8221](http://www.mysite.com/blablabla.jpg&#8221);
      alt=”” /> } ?>
    - but it dont work, i want to show an image after 5 post. i dont have any skill
      in writting script code. thanks.
 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/insert-code-after-every-x-posts/#post-7268628)
 * Hi mikataghara,
    What is the issue, the image is not displaying?
 * Also, you need to format your code above in a code block so it doesn’t break 
   this page.

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

The topic ‘Insert code after every x posts?’ is closed to new replies.

 * ![](https://ps.w.org/ajax-load-more/assets/icon-256x256.png?rev=2944639)
 * [Ajax Load More – Infinite Scroll, Load More, & Lazy Load](https://wordpress.org/plugins/ajax-load-more/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ajax-load-more/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ajax-load-more/)
 * [Active Topics](https://wordpress.org/support/plugin/ajax-load-more/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ajax-load-more/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ajax-load-more/reviews/)

 * 4 replies
 * 3 participants
 * Last reply from: [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/insert-code-after-every-x-posts/#post-7268628)
 * Status: resolved