postmeta_form_limit
云策文档标注
概述
postmeta_form_limit 是一个 WordPress 过滤器,用于控制自定义字段元框中下拉菜单显示的自定义字段数量。默认限制为 30 个,开发者可以通过此过滤器调整数量。
关键要点
- 过滤器名称:postmeta_form_limit
- 参数:$limit(整数),表示要检索的自定义字段数量,默认值为 30
- 用途:影响 meta_form() 函数在自定义字段元框中生成的下拉菜单项数
- 引入版本:WordPress 2.1.0
代码示例
add_filter( 'postmeta_form_limit', function( $limit ) {
return 50;
} );注意事项
此过滤器仅适用于自定义字段元框中的下拉菜单,不影响其他自定义字段查询。调整限制时需考虑性能影响,避免设置过高值导致加载缓慢。
原文内容
Filters the number of custom fields to retrieve for the drop-down in the Custom Fields meta box.
Parameters
$limitint-
Number of custom fields to retrieve. Default 30.
Source
$limit = apply_filters( 'postmeta_form_limit', 30 );
Changelog
| Version | Description |
|---|---|
| 2.1.0 | Introduced. |
Skip to note 2 content
Muhammad Ismail
Current default limit is 30 keys shown in the dropdown. If you want to increase the limit.
add_filter( 'postmeta_form_limit', function( $limit ) { return 50; } );