wordpress 后台取消显示custom fields(remove_meta_box)

在WordPress开发中,为了简化用户界面,通常需要隐藏custom fields(自定义字段)框。通过`remove_meta_box`函数可以实现这一目标,将参数`id`设置为`'postcustom'`。然而,该函数必须在特定的action中调用才能生效,不能直接在`register_post_type`参数中处理。官方文档提供了正确的使用示例。
摘要由CSDN通过智能技术生成

在我们用wordpress做网站的时候,存储自定义数据,需要用到custom fields,也就是自定义字段。不过,我们在提供给用户使用后台的时候,不能向他们展示custom fields框,一是让用户理解这要怎么用会比较麻烦,二是没有一个友好的界面,使用起来并不方便。
所以,我们在默认情况下,是隐藏掉custom fields框的。
怎么取消掉呢,后台的custom fields框,也是一种meta box,在remove_meta_box函数里有介绍:

      remove_meta_box( $id, $page, $context );

$id
(string) (required) Value of the id attribute of the HTML element to remove. Some of the available id values are given below:
‘authordiv’ – Author metabox
‘categorydiv’ – Categories metabox.
‘commentstatusdiv’ – Comments status metabox (discussion)
‘commentsdiv’ – Comments metabox
‘formatdiv’ – Formats metabox
‘pageparentdiv’ – Attributes metabox
‘postcustom’

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值