0

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?

1 Answer 1

1

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.

1
  • 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
    Commented Mar 13, 2013 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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