Zainicjuj przed pętlą zmienną $n = 0;
Następnie w pętli inkrementacja $n++; i modulo $n = ($n % 5);
Na końcu warunek w miejscu tego separatora <?php if($n !== 0) echo '<div class="separator">'; ?>
Dzięki za podpowiedz ale niestety nie wiem jak ją zastosować :(.
O to moja pętla:
<div id="blog">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<article>
<header>
<h1 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
</header>
<section>
<?php if ( has_post_thumbnail()) : ?>
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail(medium); ?>
</a>
<?php endif; ?>
<?php the_content('<div class="buttonleft">read more...</div>'); ?>
<div class="clr"></div>
</section>
</article>
<?php endwhile; else: ?>
<div class="brak"><p>Brak postów</p></div>
<?php endif; ?>
<br><br>
<div class="clr"></div>
</div><!--/blog-->
Jak zastosować to co napisałeś?
<div id="blog">
<$php $n=0; ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php if($n > 0) echo '<div class="separator">'; ?>
<article>
<header>
<h1 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
</header>
<section>
<?php if ( has_post_thumbnail()) : ?>
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail(medium); ?>
</a>
<?php endif; ?>
<?php the_content('<div class="buttonleft">read more...</div>'); ?>
<div class="clr"></div>
</section>
</article>
<?php $n++; ?>
<?php endwhile; else: ?>
<div class="brak"><p>Brak postów</p></div>
<?php endif; ?>
<br><br>
<div class="clr"></div>
</div><!--/blog-->