0

I have two content divs that each take up half of their containing div. My plan is to use WP_query to display the 6 most recent posts (3 in each.) It will go:

Div 1 -> post 1, post 2, post 3

Div 2 -> post 4, post 5, post 6

At the moment however it is displaying like this:

Div 1 -> post 1, post 2, post 3

Div 2 -> post 1, post 2, post 3

How can I get it to display the posts in the order of the first example? Please bear in mind that I'm still learning the Wordpress Codex.

        <?php 

        $args = array(
        'posts_per_page' => 3,
        'orderby' => 'most_recent'
        );

        $the_query = new WP_Query( $args );

        ?>

        <div class="grid_6 alpha">

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

            <a href="<?php the_permalink();?>"><h2><?php the_title(); ?></h2></a>
            <p class="meta">Published on <?php the_date(); ?> by <a href="<?php echo the_permalink();?>"><?php the_author(); ?></p></a>
            <?php the_excerpt(); ?>

        <?php endwhile; else: ?>

        <?php endif; ?>



        <?php wp_reset_postdata(); ?>



        </div>

        <?php 


        $args = array(
        'posts_per_page' => 3,
        'orderby' => 'most_recent'
        );

        $the_query = new WP_Query( $args );

        ?>

        <div class="grid_6 omega">

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

            <a href="<?php the_permalink();?>"><h2><?php the_title(); ?></h2></a>
            <p class="meta">Published on <?php the_date(); ?> by <a href="<?php echo the_permalink();?>"><?php the_author(); ?></p></a>
            <?php the_excerpt(); ?>

        <?php endwhile; else: ?>

        <?php endif; ?>

        <?php wp_reset_postdata(); ?>

        </div>
2

It appears that your first and second query are identical.

Perhaps you should add an 'offset' param in your second query.

$args = array(
    'posts_per_page' => 3,
    'orderby'        => 'most_recent',
    'offset'         => 3,
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.