Created
November 3, 2015 15:33
-
-
Save joshlevinson/e0ed3ff012b4643249d9 to your computer and use it in GitHub Desktop.
Better -1 posts_per_page for WP Query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$posts_per_page = 100; | |
$page = 1; | |
do { | |
$posts = get_posts( [ | |
'posts_per_page' => $posts_per_page, | |
'paged' => $page, | |
] ); | |
// Do stuff | |
$page++; | |
} while ( count( $posts ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment