Filter hook 'postmeta_form_keys'

in WP Core File wp-admin/includes/template.php at line 707

View Source

postmeta_form_keys

Filter Hook
Description
Filters 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.

Hook Information

File Location wp-admin/includes/template.php View on GitHub
Hook Type Filter
Line Number 707

Hook Parameters

Type Name Description
array|null $keys Pre-defined meta keys to be used in place of a postmeta query. Default null.
WP_Post $post The current post object.

Usage Examples

Basic Usage
<?php
// Hook into postmeta_form_keys
add_filter('postmeta_form_keys', 'my_custom_filter', 10, 2);

function my_custom_filter($keys, $post) {
    // Your custom filtering logic here
    return $keys;
}

Source Code Context

wp-admin/includes/template.php:707 - How this hook is used in WordPress core
<?php
 702  	 * @since 4.4.0
 703  	 *
 704  	 * @param array|null $keys Pre-defined meta keys to be used in place of a postmeta query. Default null.
 705  	 * @param WP_Post    $post The current post object.
 706  	 */
 707  	$keys = apply_filters( 'postmeta_form_keys', null, $post );
 708  
 709  	if ( null === $keys ) {
 710  		/**
 711  		 * Filters the number of custom fields to retrieve for the drop-down
 712  		 * in the Custom Fields meta box.

PHP Documentation

<?php
/**
	 * Filters 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.
	 *
	 * @since 4.4.0
	 *
	 * @param array|null $keys Pre-defined meta keys to be used in place of a postmeta query. Default null.
	 * @param WP_Post    $post The current post object.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-admin/includes/template.php
Related Hooks

Related hooks will be displayed here in future updates.