WordPress retrieve post / posts including all custom fields related to it

I'm trying to build a headless cms and trying to build a graphql schema at the moment. I was wondering is there anyway to retrieve a post including all the custom fields? at the moment I'm using CarbonFields to build the custom field if it matter. Second question will be, can I retrieve all posts including all custom fields? I know I can do the following get_post($postId); get_metadata('post', $postId); or get_post($postId); carbon_get_post_meta($postId, 'customField1'); carbon_get_post_meta($postId, 'customField2'); carbon_get_post_meta($postId, 'customField3'); but doing that way seems like I'm hitting the database multiple times unless I'm mistaken, so imagine if I need to build a schema for all posts.

Comment (0)

You’ll be in good company