View post after the last 6

1

Hello, I have a question in the condition of the constructor of the wordpress class WP_query ()

At the top of the blog I have a loop showing in a slider jquery the last 6 blog posts

  $query1 = new WP_Query( "showposts=6" );
  while ( $query1->have_posts()) : $query1->the_post();

So far right, but in the body of the blog I would like to display only the posts that came before, ie .. the last 6 in the slider and the others in the blog listing the posts

The problem is that if I put the ascending order it picks up the old posts first in the blog body

$query2 = new WP_Query( "order=ASC&showposts=+6" );
while ( $query2->have_posts()) : $query1->the_post();

The posts with the ID's get the following slider in the slider: ID 10 - ID 9 - ID 8 - ID 7 - ID 6 - ID 5 - ID 4

And on the blog: ID: 1 ID: 2 ID: 3

Understand each ID as a post

    
asked by anonymous 19.12.2016 / 21:36

2 answers

0

If you do not have to worry about pagination, offset resolves:

$query2 = new WP_Query( "showposts=6&offset=6" );
while ( $query2->have_posts()) : $query1->the_post();

offset=6 makes the query skip the first 6 posts and get the next six.

-

If you need the pagination at the bottom, you can get the IDs of the first query and exclude it from the following:

$query1 = new WP_Query( "showposts=6" );
$query1_IDs = wp_list_pluck( $query1->posts, 'ID' );
$query2 = new WP_Query( array( 'showposts' => 6, 'post__not_in' => $query1_IDs ) );
    
20.12.2016 / 17:00
-1

You can make a counter and only start from 6

while(suas condições){
for(i=0;i>=6;i++){ seu echo }
}

See if this helps you;)

    
20.12.2016 / 14:43