A
A
Alexander Timofeev2014-01-05 15:06:07
WordPress
Alexander Timofeev, 2014-01-05 15:06:07

How in WordPress to display short posts in the general list differently (i.e. depending on the even or odd post)?

There is, for example, such a code

<?php if(have_posts()) : ?> 
        <?php while(have_posts()) : the_post(); ?>  

        <br>
        <br>
        <br>
        <br>
        <article class="row">
            <div class="col-md-5"><?php the_post_thumbnail(); ?></div>
            <div class="col-md-7">
                <h2><?php the_title(); ?></h2>
                <p style="margin-top: 15px;"><?php the_content(); ?></p>
            </div>
        </article>

        <?php endwhile; ?>
        <?php endif; ?>

How can I make the even post (following this one) be displayed with the div swapped in the article?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
avalak, 2014-01-05
@aldtimofeev

Codex

<?php if ($wp_query->current_post % 2) :  ?>
// нечётное
<?php else: ?>
// чётное
<?php endif; ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question