I'm trying to build a loop using query posts to display 3 featured images from the custom post type 'portfolio'. My problem is that each picture has to be in a div with a diffrent class, so i was thinking of tree diffrent loops, but than you have a problem that sometimes a picture is showing two or three times. Also I think it is possible within one loop, i just don't know how.
What I have now is:
<div class="pc_wrapper">
<?php query_posts( 'post_type=portfolio&showposts=1' . '&orderby=rand&order=ASC&posts_per_page=-1'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="pcscreen side left"><?php $featured = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full"); ?>
<img src="<?php bloginfo('template_url');?>/thumb.php?src=<?php echo $featured[0]; ?>&w=360&h=213&zc=1&q=100&" width="360" height="210" data-thumb="<?php bloginfo('template_url');?>/thumb.php?src=<?php echo $featured[0]; ?>&w=360&h=213&zc=1&q=100&" alt="<?php the_title(); ?>" /></div>
<?php endwhile; endif; ?>
<?php query_posts( 'post_type=portfolio&showposts=1' . '&orderby=rand&order=ASC&posts_per_page=-1'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="pcscreen middle"><?php $featured = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full"); ?>
<img src="<?php bloginfo('template_url');?>/thumb.php?src=<?php echo $featured[0]; ?>&w=660&h=310&zc=1&q=100&" width="560" height="310" data-thumb="<?php bloginfo('template_url');?>/thumb.php?src=<?php echo $featured[0]; ?>&w=660&h=310&zc=1&q=100&" alt="<?php the_title(); ?>" /></div>
<?php endwhile; endif; ?>
<?php query_posts( 'post_type=portfolio&showposts=1' . '&orderby=rand&order=ASC&posts_per_page=-1'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="pcscreen side right"><?php $featured = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full"); ?>
<img src="<?php bloginfo('template_url');?>/thumb.php?src=<?php echo $featured[0]; ?>&w=360&h=213&zc=1&q=100&" width="360" height="210" data-thumb="<?php bloginfo('template_url');?>/thumb.php?src=<?php echo $featured[0]; ?>&w=360&h=213&zc=1&q=100&" alt="<?php the_title(); ?>" /></div>
<?php endwhile; endif; ?>
<?php wp_reset_query(); ?>
</div><!--/pc_wrapper-->
Is there a way to do this within one loop, and show three diffrent random pictures in the diffrent classes ( first class="pcscreen side left" second class="pcscreen middle" and third class="pcscreen side right"
I know it is possible with jquery, now sure how to do it exacly but I prefer doing it within the php loop.
Is it possible? and how?
add_image_size()
. TimThumb is a security risk and potential exploit vector; please reconsider its use.