Skip to content

WP_Query Optimization “no_found_rows”

Issue Description

Here is a way to reduce the number of queries when using WP_Query without affecting the results returned.

Affected Browsers

  • all

Issue Type

How to Fix the Issue

Its an undocumented feature, this page has a useful write up on it.

Building Efficient WordPress Queries with WP_Query

If you aren’t paginating results adding this code reduces the number of queries ran by WP_Query by 1.

Examples of where this can be used (i.e. where pagination isn’t being used)

In a website footer where you return 3 most recent posts.

Sitemap

Where more posts are ajax’d in via infinite scroll/load more button.

Fixed Code Snippets

'no_found_rows'						=> true,

References

Reference Description

Reference Link

More detail on kinsta.com

Back to Issues List