The Meta
class is an helper class to help you retrieve data of custom fields registered as post meta.
Meta::get($id, $key = '', $single = true);
$name
.This class method is equivalent to the WordPress core function: get_post_meta().
For an example, let's first build a simple metabox with custom fields:
Metabox::make('Details', 'post')->set([
Field::text('name'),
Field::checkbox('channels', ['email', 'mail', 'morse'])
]);
Then we want to retrieve the registered data:
// Should return a string
$name = Meta::get($post_id, 'name');
// Should return an array of one or more values
$channels = Meta::get($post_id, 'channels');
Made in Belgium