jon-b
12/10/2012 - 10:42 PM

Untitled 1.txt

<?php
	// Modifiy WP-Rotator
	remove_action('wp_rotator', 'wp_rotator');
	add_action('wp_rotator', 'custom_rotator');


/* Custom Rotator  */
function custom_rotator() {
	echo custom_rotator_markup();
}


/* Custom Rotator Inner Markup */

function custom_rotator_markup() {
	global $bsd_pane_width, $bsd_pane_height;
	global $post, $animate_style, $first;

	$animate_style = wp_rotator_option('animate_style');

	$result = '';
	$result .= '<div class="wp-rotator-wrap">';
	$result .= '<div class="pane">';
	$result .= '<ul class="elements" style="width: 5000px">';

	$args = array( 'post_type' => 'places' , 'posts_per_page' => 20 , 'orderby' => 'post_title' , 'order' => 'ASC' );
	$featured = new WP_Query( $args );

	$first = true;

	while ( $featured ->have_posts() ) : $featured ->the_post();
		$clickthrough_url = get_permalink($post->ID);
		$imgs = get_post_custom( $post->ID );
		foreach ( $imgs as $key => $val ) :
			if ( strpos($key, 'il_image-' ) !== false && !empty( $val[0] ) ) :
				$inner_img = '<li class="featured-cell" style="display:none;">';
				$inner_img .= '<a href="' . $clickthrough_url . '">';
			
				// If you change the width/height in WP Rotator Settings but don't use Regenerate Thumbnails plugin,
				// this will squish the image to the right dimensions rather than not changing the image.
				global $bsd_pane_height, $bsd_pane_width;
				$inner_img .= '<img width="' . $bsd_pane_width . '" height="' . $bsd_pane_height . '" src="' . $val[0] . '" />';
				$inner_img .= '</a>';
				$inner_img .= '<div class="info">'. '<h1>' . get_the_title() .'</h1>' . '</div>';
				$inner_img .= '</li><!-- featured-cell -->';
				$img_array[] = $inner_img;
			endif;
		endforeach;
	endwhile;

	shuffle($img_array);

	if ($animate_style == 'fade') {
		$img_array[0] = str_replace('style="display:none;"', '', $img_array[0]);
	}

	foreach ($img_array as $img) {
		$result .= $img;
	}

	wp_reset_query();

	$result .= '</ul><!-- elements -->';
	$result .= '</div><!-- #feature_box_rotator .pane -->';
	$result .= '</div><!-- wp-rotator-wrap -->';

	return $result;
}