Skip to content

Instantly share code, notes, and snippets.

@leifjones
Created May 25, 2017 17:51
Show Gist options
  • Save leifjones/ccdcbf6d6ede04a33ff8d9d4bedaa11b to your computer and use it in GitHub Desktop.
Save leifjones/ccdcbf6d6ede04a33ff8d9d4bedaa11b to your computer and use it in GitHub Desktop.
<?php
$query_args = array(
'foo' => 'bar',
'apple' => 'orange',
'posts_per_page' => 50,
'offset' => 0,
);
$some_posts = new WP_Query( $query_args );
while ( $some_posts->have_posts() ) {
/*
* Do some stuff here
*/
// Get more posts
$query_args['offset'] = $query_args['offset'] + $query_args['posts_per_page'];
$some_posts = new WP_Query( $query_args );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment