I know that the question was already asked but all the answer i found doesnt help me..
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 to loop :
<div class="oeuvres">
<div class="line0"><!-- should be dynamic -->
<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"><!--Should be dynamic-->
<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>
Here's the code i've already done but i got some problem : there's only 3 articles which are repeated :
<?php
//Variables needed for the template
$req = new WP_Query('category_name=creations') ; //object with the posts
$cptPosts = $req->post_count ; //nomber of post
$cptOeuvres = $cptPosts/2 ; //number of div .Oeuvres needed
$iOeuvres = 1 ; //counter of div.oeuvres
$iPost = 1 ; //counter of posts
?>
<?php echo 'cptpost = '.$cptPosts ; echo 'cptoeuvres = '.$cptOeuvres ;// to check $cptPost/$cptoeuvres value ?>
<?php if ($req->have_posts()) : ?>
<?php while($iOeuvres <= $cptOeuvres): ?>
<?php //if $iOeuvres is pair use .line1 else .line2 ?>
<?php if($iOeuvres%2 == 0) : ?>
<div class = "oeuvres">
<div class ="line1">
<?php else : ?>
<div class = "oeuvres">
<div class ="line0">
<?php endif ;?>
<?php while($req->have_posts()) : $req->the_post() ; ?>
<?php //show only 2 posts per line?>
<?php if($iPost<=2):?>
<?php //if iOeuvres is pair, image goes before ?>
<?php if($iOeuvres%2 == 0) : ?>
<div class="oeuvre">
<img class="img-oeuvre" src="<?php bloginfo('stylesheet_directory');?>/ressources/creations/lisemassages.png" alt="">
<div class="infos-oeuvre">
<p><?php the_title() ; ?></p>
<p><?php the_content() ; ?></p>
<a class="btn-oeuvre" href="http://lisemassages.fr" target="_blank">Voir le site</a>
</div><!--fermeture div.infos oeuvre-->
</div><!--fermeture div .oeuvre-->
<?php else : ?>
<div class="oeuvre">
<div class="infos-oeuvre">
<p><?php the_title() ; ?></p>
<p><?php the_content() ; ?></p>
<a class="btn-oeuvre" href="http://lisemassages.fr" target="_blank">Voir le site</a>
</div><!--fermeture div.infos oeuvre-->
<img class="img-oeuvre" src="<?php bloginfo('stylesheet_directory');?>/ressources/creations/lisemassages.png" alt="">
</div><!--fermeture div .oeuvre-->
<?php endif ; ?>
<?php $iPost++ ;?>
<?php else : ?>
<!-- $iPost > 2 : close the bracket -->
<!--of div.line and div oeuvreS -> add 1 div .oeuvreS -->
</div><!--fermeture div .line0/1-->
</div><!--fermeture div .oeuvreS-->
<?php $iPost=1; endif ;?>
<?php endwhile; ?>
<?php $iOeuvres++ ; ?>
<?php endwhile ; ?>
<?php else : ?>
<!-- no post-->
<h1>Rien du tout</h1>
<?php endif ;?>
I dont know if my code is understable ...my english either...
But my main question is how to keep the value in a innerloop when those are in an another loop .(best example in my mind is like counting room in a hotel : floor 1 : you begin with 1,2....5 and floor 2, you continue with 6,7,8...)
Any help would be great !