Answer the question
In order to leave comments, you need to log in
Different classes for WordPress posts?
I display posts on the main page through
<?php
$args = array( 'post_type' => 'post', 'posts_per_page' => 2 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
get_template_part( 'article' );
endwhile; ?>
<article class="news__item content-item item--bg-right flex">
<article class="news__item content-item item--bg-right flex">
<article class="news__item content-item content-item--left news__item--divider-left flex">
Answer the question
In order to leave comments, you need to log in
I will not write specifically for your example, I think you will take the idea and redo it for yourself, with a class it is even easier
<?php if ( have_posts() ) : $ir = 0; while ( have_posts() ) : the_post();
if ( $ir % 2 == 0 ) {
get_template_part( 'template-parts/article-wide' );
} else {
get_template_part( 'template-parts/article' );
}
$ir++; endwhile; endif; ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question