Skip to content

Instantly share code, notes, and snippets.

@JAW-Dev
Last active July 28, 2016 09:34
Show Gist options
  • Save JAW-Dev/ce790319a139e2d2b364 to your computer and use it in GitHub Desktop.
Save JAW-Dev/ce790319a139e2d2b364 to your computer and use it in GitHub Desktop.
WordPress Custom Query Paged
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$query = new WP_Query(array(
'post_type' => 'post',
'no_found_rows' => true,
'no_found_rows' => true, // useful when pagination is not needed.
'update_post_meta_cache' => false, // useful when post meta will not be utilized.
'update_post_term_cache' => false, //useful when taxonomy terms will not be utilized.
'fields' => 'ids', //useful when only the post IDs are needed (less typical).
));
if (have_posts()) :
while ($query->have_posts()) :
$query->the_post();
endwhile;
endif;
wp_reset_postdata();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment