postmeta_form_limitfilter-hookWP 2.1.0

Allows you to change the number of custom fields displayed in the drop-down list in the meta-fields meta box on the post editing screen.

Example limiting the output to 5 custom fields

This list is built from all meta-fields that have ever been added to any post on the site. Therefore, do not specify large values in the filter, as this will slow down page loading.

The value returned by this filter is passed to $wpdb->get_col() as the SQL LIMIT operator.

It runs only if the postmeta_form_keys filter returns null (the default), meaning that the specific fields to display for completion have not been specified.

Usage

add_filter( 'postmeta_form_limit', 'wp_kama_postmeta_form_limit_filter' );

/**
 * Function for `postmeta_form_limit` filter-hook.
 * 
 * @param int $limit Number of custom fields to retrieve.
 *
 * @return int
 */
function wp_kama_postmeta_form_limit_filter( $limit ){
	// filter...
	return $limit;
}
$limit(integer)
The number of custom fields displayed.
Default: 30

Examples

#1 Change the number of custom fields displayed

add_filter( 'postmeta_form_limit', 'filter_postmeta_form_limit' );
function filter_postmeta_form_limit() {
	return 5;
}

Changelog

Since 2.1.0 Introduced.

Where the hook is called

meta_form()
postmeta_form_limit
wp-admin/includes/template.php 720
$limit = apply_filters( 'postmeta_form_limit', 30 );

Where the hook is used in WordPress

Usage not found.