Stack Exchange Network
Stack Exchange network consists of 181 Q&A communities including
Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this community
Anybody can ask a question
The best answers are voted up and rise to the top
7 years, 1 month ago
This question already has answers here:
7 years ago.
I've been aware about the difference of wp_query and query_posts. I just want to know what impact does both query methods to the performance of the page? Which query method makes the page load quicker or slower?
Feb 19, 2016 at 6:11
The question was answered a few times on this site. Have a look at
Feb 19, 2016 at 7:19
Sören Wrede Sören Wrede
654 6 6 silver badges 11 11 bronze badges
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our
Accept all cookies
Necessary cookies only
get_postsare meant for non paginated queries as it breaks pagination (legally). That is why it is faster than a normal
WP_Query. If you look at the source of
get_posts, this is achieved by passing
'no_found_rows' => trueto
WP_Query. So to answer your comment, if you need a non paginated query, use
WP_Query, but then remember to pass
'no_found_rows' => trueas an argument to
WP_Query. The effect will be the same. For paginated queries, never use