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?
1 Answer
The question was answered a few times on this site. Have a look at this answer
-
3Please mark the question as duplicate. Do not post links as answers Feb 19, 2016 at 7:22
get_posts
are meant for non paginated queries as it breaks pagination (legally). That is why it is faster than a normalWP_Query
. If you look at the source ofget_posts
, this is achieved by passing'no_found_rows' => true
toWP_Query
. So to answer your comment, if you need a non paginated query, useget_posts
orWP_Query
, but then remember to pass'no_found_rows' => true
as an argument toWP_Query
. The effect will be the same. For paginated queries, never useget_posts
, useWP_query