Helper::get_metadata_default( string $meta_type, int $object_id, string $meta_key, bool $single = true )
Retrieves default metadata value for the specified meta key and object.
Description
By default, an empty string is returned if $single
is true, or an empty array if it’s false.
Parameters
- $meta_type
-
(Required) Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user', or any other object type with an associated meta table.
- $object_id
-
(Required) ID of the object metadata is for.
- $meta_key
-
(Required) Metadata key.
- $single
-
(Optional) If true, return only the first value of the specified meta_key. This parameter has no effect if meta_key is not specified. Default false.
Default value: true
Return
(mixed) Single metadata value, or array of values.
Source
File: includes/libs/helper.class.php
public static function get_metadata_default( $meta_type, $object_id, $meta_key, $single = true ){ if( function_exists( 'get_metadata_default' ) ){ return \get_metadata_default( $meta_type, $object_id, $meta_key, $single ); }elseif( $single ) { return ''; }else{ return []; } }