I have a FAQ page. Consisiting of questions. The order of the questions does not matter. What matters is the layout. Its a three column layout.
When you only have 3 questions, the layout is correct. It looks like this.
[question Z] [question A] [question O]
The problem:
When you have 4 questions the layout looks like this.
[question Z] [question A]
[question X] [question O]
It should look like this.
[question Z] [question A] [question O]
[question X]
Its a 3 column layout. I would like the questions to fill out the fist row. Than start with the second.
I need to do this, without chaning the Bootstrap grid.
The gird was set up in such a way, that when the user clicks read more on a question, only the column expand and not the row.
<?php if ( $wp_query->have_posts() ) : ?>
<?php
$counter=0;
$total_posts = $wp_query->post_count;
$posts_per_column = ceil($total_posts / 3);
?>
<section class="faq content">
<div class="container-fluid">
<div class="container-wrapper-faq">
<div class="row">
<div class="col-lg-4">
<div class="col-lg-12">
<?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); $counter++; ?>
<div class="faq-all">
<div class="faq-item">
<h2><?php the_title(); ?></h2>
<article>
<div class="faq-intro">
<?php the_content(); ?>
</div>
<div class="faq-info">
<?php the_content(); ?>
</div>
<div class="faq-link">
<a href="#" class="read-more">LES HELE SVARET</a>
<a href="#" class="read-less">LES MINDRE</a>
</div>
</article>
</div>
</div>
<!-- Close and open div if the "counter" divided by the "posts per column" of columns you want equals zero -->
<?php if($counter % $posts_per_column == 0) echo '</div></div><div class="col-lg-4"><div class="col-lg-12">'; ?>
<?php endwhile; ?>
</div>
</div>
</div>
</div>
</div>
Thanks in advance