This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
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 );
Explore the latest in WordPress
Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.