vendredi 26 décembre 2014

alternating placement of the_post_thumbnail

I have this situation where I need to alternate the placement of the_post_thumbnail(). I am looking for a better way of doing this that doesn't require so much code. The only way I could find to do it was to check for odd or even posts by doing this



while( have_posts()) : the_post();
if($query->current_post % 2){
the_post_thumbnail();
display content;
} else {
display content;
the_post_thumbnail();
}
endwhile;


This does work. I am looking for a better way. Maybe something a little more advanced that can get the same job done for less lines. The code puts the thumbnail on top of the content for even posts and on the bottom for odd posts.


Aucun commentaire:

Enregistrer un commentaire