I'm developing a custom theme using bootstrap and I'm not getting any way to create a loop to display my posts as I wanted.
I wanted my posts to follow the order:
ButtheonlyresultIgot(outsidetheinfiniteloopsrsrs)wasthis
Here'showIsetuptheloop:
<divclass="container">
<div class="row">
<div class="col-md-12 text-center titulo-blog">
<h3 class="page-h3"><?php the_title(); ?></h3>
</div>
</div>
</div>
<?php $i = 0; ?>
<?php if (($i % 2 == 0) && have_posts()): ?>
<div class="container">
<div class="row">
<div class="col-md-4 col-sm-12 imp-blog">
<?php query_posts(array(
'category_name' => 'imp',
)); ?>
<?php while (have_posts()): the_post(); ?>
<a href="<?php the_permalink(); ?>">
<div class="hoverzoom img-responsive">
<?php the_post_thumbnail(); ?>
<div class="retina">
<div class="ret-text">
<p class="ret-title"><?php the_title(); ?></p>
<p class="ret-sub"><?php the_subtitle(); ?></p>
</div>
</div>
</div>
</a>
<?php endwhile; ?>
</div>
<div class="col-md-8 col-sm-12 img-blog">
<?php query_posts(array(
'category_name' => 'img',
)); ?>
<?php while (have_posts()): the_post(); ?>
<a href="<?php the_permalink(); ?>">
<div class="hoverzoom img-responsive">
<?php the_post_thumbnail(); ?>
<div class="retina">
<div class="ret-text">
<p class="ret-title"><?php the_title(); ?></p>
<p class="ret-sub"><?php the_subtitle(); ?></p>
</div>
</div>
</div>
</a>
<?php endwhile; ?>
</div>
</div>
</div>
<? else: ?>
<div class="container">
<div class="row">
<div class="col-md-8 col-sm-12 img-blog ">
<?php query_posts(array(
'category_name' => 'img',
)); ?>
<?php while (have_posts()): the_post(); ?>
<a href="<?php the_permalink(); ?>">
<div class="hoverzoom img-responsive">
<?php the_post_thumbnail(); ?>
<div class="retina">
<div class="ret-text">
<p class="ret-title"><?php the_title(); ?></p>
<p class="ret-sub"><?php the_subtitle(); ?></p>
</div>
</div>
</div>
</a>
<?php endwhile; ?>
</div>
<div class="col-md-4 col-sm-12 imp-blog">
<?php query_posts(array(
'category_name' => 'imp',
)); ?>
<?php while (have_posts()): the_post(); ?>
<a href="<?php the_permalink(); ?>">
<div class="hoverzoom img-responsive">
<?php the_post_thumbnail(); ?>
<div class="retina">
<div class="ret-text">
<p class="ret-title"><?php the_title(); ?></p>
<p class="ret-sub"><?php the_subtitle(); ?></p>
</div>
</div>
</div>
</a>
<?php endwhile; ?>
</div>
</div>
</div>
<?php $i++; ?>
<?php endif; ?>
obs2: I created an if in which if "i" is even it follows the first order, otherwise it follows the inverse order.
Please help me I have no idea how to solve this without changing the layout