All of these cost another DB Query (each!), and worse still since they are in a loop each one happens around 300 times.
Don’t panic! The posts from your query are stored in WordPress’ object cache (which is simply memory, unless you have a custom cache system in place).
All functions that operate on posts route through this cache, so in your case there’s no extra database hit, even when you’re not in “the loop”.
You will however want to pop this line in, right after your query:
// http://wpseek.com/function/update_post_thumbnail_cache/
update_post_thumbnail_cache( $people );
This will run two extra queries (posts & post meta), which adds all thumbnails (attachments) for posts in the WP_Query
instance to the same cache.
Otherwise you will end up with a lot of queries (two for each post that has a thumbnail).
N.B: There are a few WP_Query
arguments that will change the way posts are cached:
update_post_meta_cache
(almost always yes)update_post_term_cache
(if you don’t need terms you can save a query here)fields
(if notall
, nothing is cached and above is ignored)cache_results
(if false, nothing is cached and everything above is ignored)