public
Created

  • Download Gist
gistfile1.aw
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
<?php
 
// Set up arrays to hold the post objects
$rotator_items = $testimonial_items = array();
 
// Loop through rotator items
$rotator_args = array( 'post_type' => 'rotator' );
$rotator = new WP_Query( $rotator_args );
$count = $rotator->post_count;
while( $rotator->have_posts() ): $rotator->the_post();
$rotator_items[] = $rotator;
endwhile;
 
// Loop through Testimonial items
$testimonial_args = array(
'post_type' => 'testimonial',
'posts_per_page' => $count,
);
 
$testimonial = new WP_Query($testimonial_args);
while( $testimonial->have_posts() ): $testimonial->the_post();
$testimonial_items[] = $testimonial;
endwhile;
 
// Put them together
$loop_counter = 0;
while ( $loop_counter < $count ) :
$rotator_image = get_the_post_thumbnail($rotator_items[$loop_counter]->ID, 'large');
$testimonial_image = get_the_post_thumbnail($testimonial_items[$loop_counter]->ID, 'large');
$return .= '<div>' . $rotator_image . '</div>';
$return .= '<div>' . $testimonial_image . '</div>';
$loop_counter++;
endwhile;
return $return;
 
 
// Reset the Query
wp_reset_query();

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.