Вывод постов записей wordpress в цикле по 2 в ряду (четное нечетное)
source link: https://gist.github.com/SergeyCorpus/3587dbb41c2ba19fec4489affcb5fb61
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Instantly share code, notes, and snippets.
<?php if ( have_posts() ) : ?> <?php while ( have_posts() ) :the_post(); ?>
<?php if($wp_query->current_post%2 == 0 ) : ?> <div class="services__row df"> <div class="services__item"> <div class="services__item-img"><img src="img/serv1.jpg" alt=""></div> <a class="services__item-descr" href="#"> <div class="services__item-headline"><?php the_title(); ?></div> <div class="services__item-arrow"></div> </a> </div><!-- services__item -->
<?php else : ?>
<div class="services__item"> <div class="services__item-img"><img src="img/serv2.jpg" alt=""></div> <a class="services__item-descr" href="#"> <div class="services__item-headline"><?php the_title(); ?></div> <div class="services__item-arrow"></div> </a> </div><!-- services__item -->
</div><!-- row --> <?php endif; ?>
<?php endwhile; ?> <?php endif; ?>
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK