I made an HTML page that I would like to integrate in WordPress.
The integration of the theme was done properly until I get to the posts part
I have a problem with algorithms to display posts so I know it comes from the WordPress loop.
I have done several searches on WordPress loops but I do not understand the different uses.
Here is the HTML code base that I would like automated :
<div class="oeuvres">
<div class="line0">
<div class="oeuvre">
<img class="img-oeuvre" src="ressources/creations/lisemassages.png" alt="">
<div class="infos-oeuvre">
<p>Title</p>
<p>Content</p>
<a class="btn-oeuvre" href="" target="_blank">Voir le site</a>
</div>
</div>
<div class="oeuvre">
<img class="img-oeuvre" src="ressources/creations/centredesoi.png" alt="">
<div class="infos-oeuvre">
<p>Title</p>
<p>Content</p>
<a class="btn-oeuvre" href="" target="_blank">voir le site</a>
</div>
</div>
</div><!--class line0 -->
</div>
<div class="oeuvres">
<div class="line1">
<div class="oeuvre">
<div class="infos-oeuvre">
<p>title</p>
<p>Content</p>
<a class="btn-oeuvre" href="" target="_blank">Voir le site</a>
</div>
<img class="img-oeuvre" src="ressources/creations/comparepc.png" alt="">
</div>
<div class="oeuvre">
<div class="infos-oeuvre">
<p>Title</p>
<p>Content</p>
<a class="btn-oeuvre" href="" target="_blank">voir nos créations</a>
</div>
<img class="img-oeuvre" src="ressources/creations/wine&sound.jpg" alt="">
</div>
</div><!--class line1 -->
</div>
My loop is after class “line1” However, I need this class to be dynamic: it must pass “line0” every 2 posts.
How can I change this value when it is outside the loop
Here’s the code i’ve already done, it works but not perfectly.
<div class="oeuvres">
<?php $i = 0 ; $line = "" ; ?>
//what i've try to do with those variables is to check if $i is pair or impair to change $line value but like i said its outside the loop so it doesnt change anything......
<div class="<?php echo $line ; ?>">
<?php while(have_posts()) : the_post(); ?>
<?php // $i++;
<?php //$line = ($i%0 == 0) ?"line0" : "line1" ; ?>
<div class="oeuvre">
<div class="infos-oeuvre">
<?php the_title(); ?>
<?php the_content()?>
<a class="btn-oeuvre" href="" target="_blank">Voir le site</a>
</div>
</div>
<?php endwhile; ?>
</div>
</div>
<?php endif; ?>
Any help or advice would be great !
Thanks
You can pass the class manually and do diferentes loops inside every line. Every 2 post, you add tags to the post as line0, line1, line2 and do the query with that.