• Hi,

    I want that odd and even posts would be different post types in one loop. How can i make it work? Here is the test query, which i think should work with getting odd and even ones, but how can i attach different post type here?

    $args( 'post_type' => 'TYPE' );
    
    $query = new WP_Query( $args );
    
    <?php while (have_posts()): the_post() ?>
        <?php if ($wp_query->current_post % 2 == 0): ?>
            odd
        <?php else: ?>
            even
        <?php endif ?>
    <?php endwhile ?>

    Thanks

Viewing 1 replies (of 1 total)
  • You’ve performed a query but then just used the standard query for that post. Instead you should be doing this.

    <?php while ($query->have_posts()): $query->the_post() ?>
        <?php if ($query->current_post % 2 == 0): ?>

    Also, it looks like you have the odd and even conditions the wrong way around.

Viewing 1 replies (of 1 total)
  • The topic ‘WP Query – odd/even and post types’ is closed to new replies.