Apparently there are some posts that have photo that is 2x1, and others that have photo of 1x2 (I refer to these photos):
In addition, there are 3 columns. Bootstrap can do this easily:
<div class="row">
<div class="col-md-4">
<!-- conteudo -->
</div>
<div class="col-md-4">
<!-- conteudo -->
</div>
<div class="col-md-4">
<!-- conteudo -->
</div>
</div>
Your logic, however, will have to analyze the image of each post within the loop and check:
- If this post is part of this
<div class="row">
, or you need to start another
- If the post is listed as one or two columns.
- If the post appears as two Rows, you will have to skip the third column in the next Row
Example
Obs: This is not code you can just copy and paste into your application - it’s just an attempt to show something similar to direct you on the right path.
<?php
$colunas = 3;
$coluna_corrente = 0;
$duas_rows = false;
?>
<?php if ( have_posts() ) : ?>
<?php while( have_posts() ) : the_post(); ?>
<?php
++$coluna_corrente;
if ( $coluna_corrente % $colunas == 0 ) {
echo "<div class='row'>";
}
if ( tamanho_relativa_da_foto( $colunas, $post->foto ) < 2 ) { //esse função não existe
echo '<div class="col-md-4">';
the_title();
//algo mais
echo "</div>";
} else if ( tamanho_relativa_da_foto( $colunas, $post->foto ) == 2 && !$duas_rows ) {
echo '<div class="col-md-8">';
//etc...
echo '</div>';
} else {
$duas_rows = true;
echo '<div class="col-md-4">';
//...
echo '</div>';
}
if ( $coluna_corrente == $colunas ) {
echo "</div>";
}
?>
<?php endwhile; ?>
<?php endif; ?>
Very intuitive your answer. As for the images, there will be no problems, What I really want is to respect the positioning of the layout without worrying for now with what goes inside. Can you help me to do the 3 checks in order to get the desired result? Could you show me a part to try to do the rest [PHP] ...
– Marcos Vinicius
I can offer you some psuedocode, but I won’t be able to write down exactly what you need to get what you’re trying to do - unless you want to pay my way to your country, and then I’ll be happy to go! : D
– brazilianldsjaguar
rsrsrsrs ... I will accept your small remote collaboration. Thank you.
– Marcos Vinicius