Guten Tag,
ich hab folgendes Problem: ich arbeite grade an einem Blog wo, wie der Titel des Themas schon verrät, die Beitragsbilder abwechselnd mal rechts und mal links sind. Zwar habe ich die Methode mit der Nummerierung der posts gefunden
http://forum.wpde.org/design/63294-t…mal-rechts.html
allerdings habe ich die Positionierung des Beitrags und der Beitragsbilder nicht im CSS festgelegt, sondern direkt im loop
<section class="page-section-upcoming">
<?php if(have_posts()) : ?>
<?php while(have_posts()) : the_post(); ?>
<div class="container absolute" style="margin-top: 20px; padding-right: 0px; padding-left: 0px;">
<div class="col-sm-9 col-md-6 col-lg-6 mb-md-50 post-thumbnail hidden-sm hidden-xs" style=" background-color: #fff; min-height: 550px; margin-bottom: 0px; padding-right: 0px; padding-left: 0px;">
<?php if(has_post_thumbnail()) : ?>
<?php the_post_thumbnail(); ?>
<?php endif; ?>
</div>
<div class="col-sm-9 col-md-6 col-lg-6 mb-md-50" style="background: #fff; min-height: 550px; margin-bottom: 0px;">
<!-- Post Title -->
<h2 class="blog-item-title font-alt"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<!-- Author, Categories, Comments -->
<div class="blog-item-data">
<a href=""><?php the_category(); ?></a>
</div>
<div class="blog-item-date">
<span class="date-num"><?php the_time("d"); ?></span><?php the_time("M"); ?>
</div>
<p>
<?php the_excerpt(); ?>
</p>
<div class="blog-item-foot">
<a href="<?php the_permalink(); ?>" class="btn btn-mod btn-border-w btn-medium btn-round hidden-xs" style="background: #cd9943; color: #fff;"">Read More <i class="fa fa-angle-right"></i></a>
</div>
</div>
<?php the_post(); ?>
<div class="col-sm-9 col-md-6 col-lg-6 mb-md-50" style="background-color: #fff; min-height: 550px; margin-bottom: 0px;">
<!-- Post Title -->
<h2 class="blog-item-title font-alt"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<!-- Author, Categories, Comments -->
<div class="blog-item-data">
<a href=""><?php the_category(); ?></a>
</div>
<div class="blog-item-date-sec">
<span class="date-num"><?php the_time("d"); ?></span><?php the_time("M"); ?>
</div>
<p>
<?php the_excerpt(); ?>
</p>
<div class="blog-item-foot">
<a href="<?php the_permalink(); ?>" class="btn btn-mod btn-border-w btn-medium btn-round hidden-xs" style="background-color: #cd9943; color: #fff;">Read More <i class="fa fa-angle-right"></i></a>
</div>
</div>
<div class="col-sm-9 col-md-6 col-lg-6 mb-md-50 post-thumbnail hidden-sm hidden-xs" style="margin-bottom: 0px; min-height: 550px; background-color: #fff; padding-right: 0px; padding-left: 0px;">
<?php if(has_post_thumbnail()) : ?>
<?php the_post_thumbnail(); ?>
<?php endif; ?>
</div>
<?php endwhile; ?>
<?php else : ?>
<p><?php __('No Posts'); ?></p>
<?php endif; ?>
</div>
</section>
Alles anzeigen
Also ich habe den zweiten Beitrag einfach "gespiegelt".
Mein Problem ist nun, dass sobald die Anzahl der Beträge ungerade ist erscheint der "gespiegelte Beitrag" trotzdem am Ende als leere Columns. Gibt es eine einfache Möglichkeit den Loop zu beenden bevor der zweite Beitrag ausgegeben wird? Habe einiges probiert und bis jetzt hat nichts funktioniert.
Danke schonmal für Eure Hilfe und seid bitte nicht allzu streng mit mir und dem Code.