Last active
August 29, 2015 14:10
-
-
Save scheurta/8ec63b2bdc3a8eb6ac9b to your computer and use it in GitHub Desktop.
Optimized WP_Query for retrieving all posts
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
$args = array( | |
'post_type' => 'post', | |
'post_status' => 'publish', | |
'nopaging' => true, // remove if pagination is required | |
'no_found_rows' => true, // remove if pagination is required | |
'update_post_term_cache' => false, | |
'update_post_meta_cache' => false, | |
); | |
$query = new WP_Query( $args ); | |
if ( $query->have_posts() ) : | |
//... | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment