get_post_meta
takes 3 params, not two:
get_post_meta( int $post_id, string $key = '', bool $single = false )
As you can see, the third param is false by default. It means, that if you don’t pass it, the function will return an array with all custom fields for that key.
If you have only one meta field with key prep_time
, you’ll get:
Array( 0 => "30" )
On the other hand I’m pretty sure that’s not what you’re expecting, so you should pass true
as the third param like so:
$build['time'] = get_post_meta($id, 'prep_time', true);