Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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>
share|improve this question
    
See this answer. –  Milo Mar 16 at 3:05

1 Answer 1

up vote 0 down vote accepted

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,
);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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