Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

There's no mention of custom fields values in Get_post's codex page. Is it impossible to use get_post to get a custom field value of some post, and if so, is it necessary to perform a whole loop just for that?

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

All of the custom field functions accept the post id as a parameter. You can use all those functions directly without the need to actually retrieve the post itself.

share|improve this answer
1  
Also, when fetching with get_posts, WP_Query, etc, all meta fields and taxonomies are usually prefetched and cached, so each call to get_post_meta will be server from cache rather than hitting the db. –  kovshenin Mar 13 '13 at 20:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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