[wp-hackers] WP_Query vs. get_posts

Josh joshua.sibelman at gmail.com
Mon Oct 29 21:30:46 UTC 2012

I have a general question about which of these is most ideal for use in shortcodes.

I currently use Posts 2 Posts a lot in tandem with shortcodes to display connected data for a post. In the shortcodes I have traditionally used get_posts to retrieve the connected data, but reading the Posts 2 Posts documentation I see that there's a way to interact with a WP_Query object to more efficiently grab all the connected posts. 

This raises a question in my mind generally regarding the relative efficiency of get_posts vs. WP_Query. Looking at the amount of data in the WP_Query object, it's starting to look to me like that's generally a superior way to retrieve post data than get_posts. 

Do any of you have a particular preference for one over the other, and if so why?


Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

More information about the wp-hackers mailing list