I'm using a wordpress theme and I do want to change the css of 2 blocks using php when the value of certain variable is even or odd..
this is my code :
<?php
$i = 0;
while ( have_posts() ) {
// Override
if(($i % 2) == 1) { ?>
<style type="text/css">
.grid-box-img {
width: 54%;
float: left;
}
.entry-head {
width: 56%;
background-color: #fff;
position: absolute;
z-index: 10;
margin-left: 43%;
margin-top: 27%;
}
</style>
<?php
}
else { ?>
<style type="text/css">
.grid-box-img {
width: 54%;
float: right;
}
.entry-head {
width: 56%;
background-color: #fff;
position: absolute;
z-index: 10;
margin-top: 27%;
}
</style>
<?php
}
$i++;
the_post();
} ?>
But, unfortunately it doesn't work... It applies only the CSS of the last value.
How can I do that ? Thank you :)