php - WordPress get post thumbnails in a custom pattern -


right have each post 2 sizes thumbnail:

$big = wp_get_attachment_image_src( get_post_thumbnail_id( $post->id ), 'thumbnail_600x200' ); $small = wp_get_attachment_image_src( get_post_thumbnail_id( $post->id ), 'thumbnail_200x100' ); 

what trying achieve display posts using next pattern:

post 1 - [big thumbail]
post 2 - [small thumbail]
post 3 - [small thumbail]
post 4 - [big thumbail]
post 5 - [small thumbail]
post 6 - [small thumbail]

actually posts shown big - small - small - big - small -small , on.

any idea? thank you

this post foreach:

<?php foreach ($posts $post) {      $big = wp_get_attachment_image_src( get_post_thumbnail_id( $post->id ), 'thumbnail_600x200' );     $small = wp_get_attachment_image_src( get_post_thumbnail_id( $post->id ), 'thumbnail_200x100' );      if ( $big ) { ?>         <img src="<?php echo $big['0']; ?>" />     <?php }else{ ?>         <img src="http://placehold.it/600x200/7f8c8d/ffffff" alt="featured image missing"/>     <?php } ?> <?php } ?> 

make counter outside function.

inside function, increment counter. before that, check if countr % 3 == 0.

if so, show big thumbnail.

<?php  $counter = 0;  foreach ($posts $post) {           if($counter %3 == 0)         {            $big = wp_get_attachment_image_src( get_post_thumbnail_id( $post->id ), 'thumbnail_600x200' );         }else{            $small = wp_get_attachment_image_src( get_post_thumbnail_id( $post->id ), 'thumbnail_200x100' );         }      if ( $big ) { ?>         <img src="<?php echo $big['0']; ?>" />     <?php }else{ ?>         <img src="http://placehold.it/600x200/7f8c8d/ffffff" alt="featured image missing"/>     <?php } ?>   counter++; //increase counter <?php } ?> 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -