postmeta_form_keys filter
Filters values for the meta key dropdown in the Custom Fields meta box.
apply_filters( 'postmeta_form_keys', array|null $keys, WP_Post $post )
Description
This is filter hook , its filter values for the meta key dropdown in the Custom Fields meta box..
Returning a non-null value will effectively short-circuit and avoid a potentially expensive query against postmeta.
Its consists of two parameters, one is $keys, second is $post object.
Its used by meta_form() which print the form in the Custom Fields meta box.
Parameters
- $keys : (array|null) Pre-defined meta keys to be used in place of a postmeta query. Default null.
- $post : (WP_Post) The current post object.
Live Example
To run the hook, copy the example below.
apply_filters( 'postmeta_form_keys', array|null $keys, WP_Post $post )
The following example is for adding a hook callback.
add_filter('postmeta_form_keys','meta_form_keys'); function meta_form_keys($keys, $post ) { return $keys; }
To remove a hook callback, use the example below.
// remove the filter add_filter( 'postmeta_form_keys', 'meta_form_keys', 10, 1 );