Get the current post meta value.
This function is a shortcut of get_post_meta().
beans_get_post_meta( string $field_id, mixed $default = false, $post_id = false )
Return: (mixed) Saved data if exist, otherwise default value set.
Parameters
Name | Type | Required | Default | Description |
---|---|---|---|---|
$field_id | string | true | - | The post meta id searched. |
$default | mixed | false | false | The default value to return of the post meta value doesn't exist. |
$term_id | int | false | - | Overwrite the current post id. |
Source
function beans_get_post_meta( $field_id, $default = false, $post_id = false ) {
if ( ! $post_id ) {
$post_id = ! ( $id = get_the_id() ) ? beans_get( 'post' ): $id;
}
$post_meta = get_post_meta( $post_id );
if ( isset( $post_meta[ $field_id ] ) ) {
return get_post_meta( $post_id, $field_id, true );
}
return $default;
}