Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. $limit = 200;
  2. $offset = 0;
  3. while (TRUE) {
  4. $posts = new WP_Query(array(
  5. 'posts_per_page' => $limit,
  6. 'offset' => $offset,
  7. 'post_type' => $post_type,
  8. 'orderby' => 'title',
  9. 'order' => 'ASC',
  10. 'post_status' => array('publish', 'private', 'draft', 'inherit'),
  11. ));
  12.  
  13. if (!$posts->have_posts()) break;
  14.  
  15. while($posts->have_posts())
  16. {
  17. $posts->the_post();
  18.  
  19. # do some echoing with the $post
  20. }
  21.  
  22. $offset += $limit;
  23. } /*(TRUE)*/
  24.  
  25. # do some echoing with the $post
  26.  
  27. # wipe post from memory
  28. wp_cache_delete( $post->ID, 'posts' );
  29. wp_cache_delete( $post->ID, 'post_meta' );
  30.  
  31. wp_cache_flush();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement