0

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?

7
  • See my answer in the duplicate. I wrote an extensive answer on this Feb 19, 2016 at 7:24
  • 2
    Also, you have to read my answer here Feb 19, 2016 at 7:26
  • Hi, you again @pieter. you've been helping me a lot. Well, i just don't understand one thing, Should i use get_posts or wp_query for maximizing load performance? Feb 19, 2016 at 7:33
  • get_posts are 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' => true to WP_Query. So to answer your comment, if you need a non paginated query, use get_posts or WP_Query, but then remember to pass 'no_found_rows' => true as an argument to WP_Query. The effect will be the same. For paginated queries, never use get_posts, use WP_query Feb 19, 2016 at 7:41
  • Ok, That's great to know. Thank you again, @pieter. So if i use get_posts to fetch an image url for the post's banner, it will be faster than using wp_query? and also, does get_posts uses the same arguments as wp_query? Feb 19, 2016 at 7:48

1 Answer 1

-1

The question was answered a few times on this site. Have a look at this answer

1
  • 3
    Please mark the question as duplicate. Do not post links as answers Feb 19, 2016 at 7:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.