admin管理员组文章数量:1328037
I've created a custom meta box to handle certain custom post meta fields and I don't want the clutter of having these custom fields duplicated down in the "Custom Fields" area.
How can I remove specific custom post meta from the "Custom Fields" fieldset?
I've created a custom meta box to handle certain custom post meta fields and I don't want the clutter of having these custom fields duplicated down in the "Custom Fields" area.
How can I remove specific custom post meta from the "Custom Fields" fieldset?
Share Improve this question asked Sep 15, 2010 at 16:18 Scott BScott B 5,69614 gold badges94 silver badges148 bronze badges 1- Can anyone provide a suggestion on how to use the is_protected_meta hook to hide multiple custom field keys based on a substring that’s in the key name? There’a plugin that I’m using that added a whole bunch of custom field keys and I want to hide them from the admin interface without breaking the plugin. For example, I want to hide ALL custom field keys that start with “review-” or “bsf-” – technabob Commented Jul 26, 2020 at 21:09
2 Answers
Reset to default 2To hide a custom field from the "Custom Fields" section, prefix it with an underscore. So add_post_meta($id, 'name', 'value');
becomes add_post_meta($id, '_name', 'value');
.
Here's a good reference for backup:
- How to Hide Your Plugin's Custom Fields
You can hook into the is_protected_meta filter and return true for any custom field you want to hide.
add_filter('is_protected_meta', 'my_is_protected_meta_filter', 10, 2);
function my_is_protected_meta_filter($protected, $meta_key) {
return $meta_key == 'meta-name' ? true : $protected;
}
本文标签: theme developmentHow can I remove specific custom post meta from the quotCustom Fieldsquot fieldset
版权声明:本文标题:theme development - How can I remove specific custom post meta from the "Custom Fields" fieldset? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742231376a2437277.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论