apply_filters( "get_{$meta_type}_metadata", null|array|string $value , int $object_id , string $meta_key , bool $single )
Filters whether to retrieve metadata of a specific type.
Description Description
The dynamic portion of the hook, $meta_type
, refers to the meta object type (comment, post, term, or user). Returning a non-null value will effectively short-circuit the function.
Parameters Parameters
- $value
-
(null|array|string) The value get_metadata() should return - a single metadata value, or an array of values.
- $object_id
-
(int) Object ID.
- $meta_key
-
(string) Meta key.
- $single
-
(bool) Whether to return only the first value of the specified $meta_key.
Source Source
File: wp-includes/meta.php
Changelog Changelog
Version | Description |
---|---|
3.1.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Note that although this filter filters the value that will be returned, you do not receive the current value as the first parameter.
You allways receive
null
in the first parameter.If your callback returns anything else than null, this is the value that the function will return at the end. If you return null, the function will continue to run normally and try to fetch the data from the database (or cache).
Feedback
Actually – you do not “always receive NULL” as the first parameter.While it is true that WordPress calls the first (as possibly ONLY) filter in the sequence with a NULL $value, you should allow for the possibility that a higher-priority filter could be passing down a $value to your filter!To play nice with other plug-ins, rather than your filter returning a hard-coded “null” if it decides to take no action, it may be appropriate for your filter to return the $value (which may be null, or may be the value injected by an earlier filter!) — By Andy Schmidt —