Getting meta data from a WP_Post
object is already possible. Just write:
echo $post->your_meta_key;
This will call get_post_meta( $this->ID, $your_meta_key, true )
behind the scenes.
See the documentation and the source code for WP_Post
.
This works also with instances of WP_User
, but not with WP_Comment
as far as I know.
Don’t forget to escape the output!