Title: Multiple Custom Post type with intervals
Last modified: August 21, 2016

---

# Multiple Custom Post type with intervals

 *  [stripeaccess](https://wordpress.org/support/users/stripeaccess/)
 * (@stripeaccess)
 * [12 years, 12 months ago](https://wordpress.org/support/topic/multiple-custom-post-type-with-intervals/)
 * I am trying to create a loop for a slider using two different post types “slides”
   and “testimonials”. This is my aim result.
    slide 1 -> slide 2 -> slide 3 -> **
   testimonial 1** -> slide 1 -> slide 2 -> slide 3 -> **testimonial 2** -> slide
   1 -> slide 2 -> slide 3 -> **testimonial 3** -> I am able to produce the loop
   but I’m stuck with the interval.

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

 *  [graphicgeek](https://wordpress.org/support/users/graphicgeek/)
 * (@graphicgeek)
 * [12 years, 12 months ago](https://wordpress.org/support/topic/multiple-custom-post-type-with-intervals/#post-3837865)
 * This sounds very tricky. I would try using the Modulus operator to trigger a 
   testimonial query after every 3rd slide.
 *  Thread Starter [stripeaccess](https://wordpress.org/support/users/stripeaccess/)
 * (@stripeaccess)
 * [12 years, 12 months ago](https://wordpress.org/support/topic/multiple-custom-post-type-with-intervals/#post-3837883)
 * Thanks graphicgeek. I tried your suggestion using modulus operator and here goes
   my query below
 *     ```
       <?php
          global $post;
           $args = array(
       	 'orderby' => 'menu_order',
       	 'order' => 'ASC',
       	 'showposts' => 15,
            'post_type' => array( 'slideimages' )
            );
        ?>
   
            <div id="slider">
   
       <ul>
   
       <?php
       	$intervalpost = new WP_Query($args);
       	$count=1;
   
       	while ( $intervalpost->have_posts() ) : $intervalpost->the_post(); global $post; ?>
   
               <li style="color: #fff;"><?php the_content();?></li>
       		<?php
       		$count++;
               if ($count % 5 == 0 || $count % 9 == 0 || $count % 13 == 0){     
   
       		 $argsnew = array(
       		 'orderby' => 'menu_order',
       		 'order' => 'ASC',
       		 'posts_per_page' => 1,
       		 'offset' => 0,
       		 'post_type' => array( 'testi' )
       		 ); 
   
       		 if ($count % 5 == 0 || $count % 9 == 0 || $count % 13 == 0){
       		 }
   
       		 $the_query = new WP_Query( $argsnew );
       		while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
   
                     <li style="color: #fff;"><?php the_title();?> <br /> <?php the_content();?></li>
   
       			 <?php endwhile;
   
             // Reset Second Loop Post Data
             wp_reset_postdata(); 
   
               }?>  
   
       		<?php endwhile;
       	echo '</ul>';
       	echo '</div>';
       	 ?>
       ```
   
 * Now my problem is that, the result goes this way.
 * slide 1 -> slide 2 -> slide 3 -> testimonial 1 ->
    slide 1 -> slide 2 -> slide
   3 -> testimonial 1 -> slide 1 -> slide 2 -> slide 3 -> testimonial 1 ->
 *  [graphicgeek](https://wordpress.org/support/users/graphicgeek/)
 * (@graphicgeek)
 * [12 years, 12 months ago](https://wordpress.org/support/topic/multiple-custom-post-type-with-intervals/#post-3837967)
 * Try using a second counter to count the number of times the testimonial query
   has been run, something like $testimonialcount, and then use this for $argsnew:
 *     ```
       $argsnew = array(
       		 'orderby' => 'menu_order',
       		 'order' => 'ASC',
       		 'posts_per_page' => 1,
       		 'offset' => $testimonialcount,
       		 'post_type' => array( 'testi' )
       		 );
       ```
   
 * Also, for your if statement, you may be able to simplify it to if($count % 3 
   == 0) This would return true when the count is 0, 3, 6, 9, etc
 * Hope that helps.

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

The topic ‘Multiple Custom Post type with intervals’ is closed to new replies.

## Tags

 * [custom post type](https://wordpress.org/support/topic-tag/custom-post-type/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [graphicgeek](https://wordpress.org/support/users/graphicgeek/)
 * Last activity: [12 years, 12 months ago](https://wordpress.org/support/topic/multiple-custom-post-type-with-intervals/#post-3837967)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
