Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created February 7, 2012 21:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save billerickson/1762204 to your computer and use it in GitHub Desktop.
<?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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment