lundi 15 mai 2017

randomly add a class inside a php loop

I'm using a php loop on my website. I'm trying to randomly add a class "current" to a div inside this loop. I know how to do it using jQuery but I'd liek to use php to achieve this. here is my loop :

<?php if (have_posts()) : ?>
<div id="random_backgrounds">
<?php while (have_posts()) : the_post(); ?>
<div id="background_directors" class="" background_ID="<?php the_ID();?>" style="background: url(<?php the_post_thumbnail_url( 'large' ); ?>) no-repeat center center fixed" ></div>
<?php endwhile; ?>
</div>
<?php endif; ?>

I'd like to add the "current" class randomly to the "background_directors" div.

can anybody help me with this ?




Aucun commentaire:

Enregistrer un commentaire