Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeweltheme/934fbf25f07d1e863d315bacb66aa1f3 to your computer and use it in GitHub Desktop.
Save jeweltheme/934fbf25f07d1e863d315bacb66aa1f3 to your computer and use it in GitHub Desktop.
Improve performance of the WordPress WP_Query
<?php
$args = array(
// Normal query goes here //
'no_found_rows' => true, // counts posts, remove if pagination required
'update_post_term_cache' => false, // grabs terms, remove if terms required (category, tag...)
'update_post_meta_cache' => false, // grabs post meta, remove if post meta required
);
$loop = new WP_Query( $args );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment