acf_get_metaref()
acf_get_metaref
Retrieves reference metadata from the database.
No Hooks.
Returns
Mixed.
Usage
acf_get_metaref( $post_id, $type, $name );
- $post_id((int|string))
- The post id.
- $type
- .
Default:'fields' - $name(string)
- An optional specific name.
Default:''
Changelog
| Since 5.2.3 | Introduced. |
acf_get_metaref() acf get metaref code ACF 6.0.4
function acf_get_metaref( $post_id = 0, $type = 'fields', $name = '' ) {
// Load existing meta.
$meta = acf_get_metadata( $post_id, "_acf_$type" );
// Handle no meta.
if ( ! $meta ) {
return $name ? '' : array();
}
// Return specific reference.
if ( $name ) {
return isset( $meta[ $name ] ) ? $meta[ $name ] : '';
// Or return all references.
} else {
return $meta;
}
}